-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Do not rely on external stack frame to exist #12771
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
When using matplotlib in an embedded Python interpreter (such as in Julia package PyCall.jl), stack frame may not exist outside matplotlib. Therefore, it is better to not assume `frame.f_back` to be an existing call frame. See: JuliaPy/PyPlot.jl#409
@@ -1990,6 +1990,8 @@ def _warn_external(message, category=None): | |||
""" | |||
frame = sys._getframe() | |||
for stacklevel in itertools.count(1): # lgtm[py/unused-loop-variable] | |||
if frame is None: |
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.
Would suggest leaving a comment (as just below) so that people realize when this can happen.
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 took the liberty of adding such a comment
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.
modulo comment as to why
thanks all! |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
Thanks for the prompt review and merge! |
…exist Conflicts: lib/matplotlib/cbook/__init__.py - also backported lgtm noqa flag
PR Summary
When using matplotlib in an embedded Python interpreter (such as in Julia package PyCall.jl), stack frame may not exist outside matplotlib. Therefore, it is better to not assume
frame.f_back
to be an existing call frame.See: JuliaPy/PyPlot.jl#409
PR Checklist