-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fixes #653 use deprecated_call as context_manager #1041
Conversation
""" | ||
if not func: | ||
warnings.simplefilter('always') |
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.
the simplefilter happening outside of a context manager affects global state
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.
is moving warnings.simplefilter('always')
inside WarningsChecker.__enter__
a solution?
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.
it already does that, see the line before return
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.
Ah, I've found that, currently am trying to figure out why it only works if append=True is unset:
WarningsRecorder.__enter__:warnings.simplefilter('always')
- works fine
WarningsRecorder.__enter__:warnings.simplefilter('always', append=True)
- the existing code, breaks my PR tests
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.
append decides whether the filter is inserted at the end or the beginning in the warnings filter list
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.
Yes, but I have not yet figured out why that would change the outcome of the deprecated_call
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 believe this is because in a list of filters - the first one that matches will apply, and upon inspecting the filters (before the always
is appended):
[('ignore', None, <type 'exceptions.DeprecationWarning'>, None, 0),
('ignore', None, <type 'exceptions.PendingDeprecationWarning'>, None, 0),
('ignore', None, <type 'exceptions.ImportWarning'>, None, 0),
('ignore', None, <type 'exceptions.BytesWarning'>, None, 0)]
I see now why appending always
will never work. The question is : is there a point in appending this filter in the first place(instead of prepending) since it is possible to have one that will match before it(being shadowed).
I am, will do |
Discussed with @flub that it doesn't make sense to append the filter |
good investigative work instead of merging master, please use a rebase and a force push so we can keep the main history less eratic |
c3ce7a0
to
9f77a85
Compare
ok, done |
please retarget to "features" branch -- "master" is since today meant for bugfixes only. sorry for the inconvenience. |
we can manually merge into feature |
@RonnyPfannschmidt I didn't understand your comment, should I branch my code from feature instead and create a new PR? I am happy to do that. Is there maybe an easier way? |
@chiller i'll merge myself in a bit (github does not have an ui to make the same pull request against different branch without a mess) |
it was merged into the features branch |
thanks |
No description provided.