You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The with statement was supposed to close the file, making it impossible to later read the arrays from it. (Without this, the with statement is useless: its purpose is to prevent file-handle leaks, and nothing here is closing the file-handle.)
This is where the "file" object (a ReadOnlyDirectory) has an __exit__ method that gets called at the end of the with statement:
Now I wonder why pytest is not complaining about the leaking file-handles. I know that it checks for unclosed files because I've seen that error. Here it is, reproduced on the terminal, and our test suite never raised an error. I don't understand that.
Socially, this could be a problem because the fsspec-based file-handles have been available for almost a year (Uproot 5) and users might have gotten used to opening the file in a with statement (uselessly) and later, outside the with, initiating more file-reading with TTree, RNTuple, and TDirectory objects. After fixing this, code that relied on this error will break. It will need to be a new minor version number, 5.4.0, at least.
The text was updated successfully, but these errors were encountered:
I saw this in @giedrius2020's talk.
The
with
statement was supposed to close the file, making it impossible to later read the arrays from it. (Without this, thewith
statement is useless: its purpose is to prevent file-handle leaks, and nothing here is closing the file-handle.)This is where the "
file
" object (a ReadOnlyDirectory) has an__exit__
method that gets called at the end of thewith
statement:uproot5/src/uproot/reading.py
Lines 1515 to 1516 in dc19ce9
and here is where that gets propagated to an FSSpecSource:
uproot5/src/uproot/source/fsspec.py
Lines 81 to 83 in dc19ce9
and here's the pre-fsspec Source (MemmapSource):
uproot5/src/uproot/source/file.py
Lines 216 to 223 in dc19ce9
Pre-fsspec file-handles got closed:
Now I wonder why pytest is not complaining about the leaking file-handles. I know that it checks for unclosed files because I've seen that error. Here it is, reproduced on the terminal, and our test suite never raised an error. I don't understand that.
Socially, this could be a problem because the fsspec-based file-handles have been available for almost a year (Uproot 5) and users might have gotten used to opening the file in a
with
statement (uselessly) and later, outside thewith
, initiating more file-reading with TTree, RNTuple, and TDirectory objects. After fixing this, code that relied on this error will break. It will need to be a new minor version number, 5.4.0, at least.The text was updated successfully, but these errors were encountered: