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
BUG: Ensure import astropy.coordinates works with -OO optimize flag #15037
Conversation
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
mpldev failure is unrelated |
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 @pllim! From my perspective this is good and it accomplishes the minimal goal of making astropy functional when python is run with the -OO
flag. It would be nice to see documentation in the PR description of the functional testing since there are no unit tests that cover this.
Whether this should be merged without some resolution of the other issues in #15028 is another question.
I thought about maybe adding a job to test for |
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'm not against merging this as is, but maybe it would be better to check sys.flags.optimize
explicitly, in which case the new code comments would not be needed.
@eerovaher , are you saying to only run the affected code for |
Yes, except that the |
But what does "Currently Nuitka sets optimize=1 for flag -OO" mean? |
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 looks good, but should one of our tests be adjusted to run with -OO
? Though I'm not sure pytest
can work in that case!! Anyway, am approving here since I think it can be a separate issue.
Nuitka is 3rd party software. Last week it incorrectly set optimize=1 when python flag is -OO. This problem was fixed in the factory release (not on pip yet) of Nuitka. I thought the problem I'm seeing in my code that uses both Nuitka and Astropy was caused by Astropy not handling the python -OO flag, but now I think there are 3 separate (but maybe related) issues: Astropy -OO problem (this PR), Nuitka optimize flag incorrect setting (fixed in Nuitka), and an unresolved issue. |
Interesting, so those two patches together still did not fix everything? What else? |
I'm really not sure. My plan was to try to update ply and see if that helped, but I'm not getting anywhere with that due to my limited python skills. My next idea is to wait until this PR and Nuitka's fix are in the mainline versions of both code bases and try again with clean installs of each. (I don't have high hopes this will fix the problem because my local versions show improvement for simplified tests of each bug, so I think I applied the fixes correctly.) |
does not crash when called with Python -OO flag because cls.__doc__ is None in that case.
Given the conversation thus far, I am not convinced that strict optimize flag check is any nicer than the existing one, as it seems like I will also open a follow up issue about testing. See #15052 Thank you, all! |
|
…ks with -OO optimize flag
I suggested explicitly checking |
…037-on-v5.3.x Backport PR #15037 on branch v5.3.x (BUG: Ensure import astropy.coordinates works with -OO optimize flag)
Description
This pull request is to ensure
import astropy.coordinates
does not crash when called with Python-OO
flag becausecls.__doc__
isNone
in that case. Just don't expect nice docstring for the affected API when you use that flag.Fixes #15028