-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
replace KeyError with LookupError in the types of possible read_hdf errors #52783
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
Conversation
pandas/io/pytables.py
Outdated
@@ -455,7 +455,7 @@ def read_hdf( | |||
chunksize=chunksize, | |||
auto_close=auto_close, | |||
) | |||
except (ValueError, TypeError, KeyError): | |||
except (ValueError, TypeError, KeyError, IndexError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably this should just be
except (ValueError, TypeError, KeyError, IndexError): | |
except BaseException: |
as when using with HDFStore(...):
it will still close on all exceptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense (I'm not sure if we have a linting rule that may complain about BaseException
but worth a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks could you add a test and whatsnew entry for this (v2.1.0.rst
)
yep I'm just working on a test now |
@mroeschke what do you think about using BaseException instead? |
# smoke test to test that file is properly closed after | ||
# read with IndexError before another write | ||
df.to_hdf(path, "k1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# smoke test to test that file is properly closed after | |
# read with IndexError before another write | |
df.to_hdf(path, "k1") | |
# smoke test to test that file is properly closed after | |
# read with IndexError before another write | |
with tm.assert_produces_warning(None): | |
df.to_hdf(path, "k1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would this produce a warning? If the file is already open an exception is raised regardless of warning filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change would need to be in test_read_missing_key_opened_store also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just to help assert something additional with this call (that no warning is raised)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's correct to do that here
Thanks @graingert |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.