-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seek and read from closed MemoryIO #1539
Comments
This also affects opening and reading from regular files: import asdf
import numpy
fn = 'test.asdf'
arrs = [numpy.arange(10) + i for i in range(10)]
af = asdf.AsdfFile({'arrs': arrs})
af.write_to(fn)
fp = open(fn, 'rb')
with asdf.open(fp) as raf:
arefs = raf['arrs']
print(fp.tell())
print(arefs[1][:])
print(fp.tell()) 2902
[ 1 2 3 4 5 6 7 8 9 10]
1830 |
Fixed in #1537 both examples above now no longer seek the file pointer and raise an exception:
|
braingram
added a commit
to braingram/jwst
that referenced
this issue
Oct 6, 2023
asdf previously had a bug where contents from a closed file could be accessed. See: asdf-format/asdf#1539 The cube build step was relying on this bug, closing models before the wcs was fully read (this is lazy loaded). This commit prevents the early model closure.
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ASDF will read from a 'closed'
generic_io.MemoryIO
(like what is created when reading from anio.BytesIO
instance).Running the following:
produces:
showing that the array loading from the 'closed'
MemoryIO
resulting in a change in the file pointer position.The text was updated successfully, but these errors were encountered: