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: Fix loading parser tabs on pyc-only installations #16159
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.
|
Thanks! This is subtle behavior change, so would need a change log, but I cannot decide between "api" within |
It looks like the code could be simplified by using |
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.
These seem like good changes, thanks! Do you think it would be possible to test them by expanding utils/tests/test_parser.py
? The code looks obviously right to me, but a test would help ensure we don't regress...
As far as the type of change is concerned, I feel this is a feature rather than an API change (or maybe bug fix). I guess it is a bit like performance
.
I added a unit test, but it's not yet passing. Even if I remove the byte-compilation it fails, so I think that it is probably my test that is not quite right. |
Tests ought to pass now. I had to add a |
@@ -35,6 +36,9 @@ def t_NUMBER(t): | |||
t.value = int(t.value) | |||
return t | |||
|
|||
def t_error(t): |
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 this being required an indication of anything more serious?
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 so. Just that PLY lacks a sensible default for t_error
if the lexer does not provide one.
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.
Great, I like the added test - nice & simple. Thanks so much @lpsinger!
Ah, I guess we still have the question of the changelog entry. I'm now a bit less sure than I was before, and think @pllim's suggestion of "other" in the top level is probably most appropriate. |
OK, I added a changelog entry. |
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.
Great, thanks!
According to the Python module loading [flow chart](https://peps.python.org/pep-3147/#flow-chart), when evaluating `import foo` and `foo.py` is not found, Python then reads `foo.pyc`. One can take advantage of this fact to strip source files and leave only Python bytecode files for deployment in space-constrained execution environments such as AWS Lambda (see, for example, nasa-gcn/gcn.nasa.gov#2040). Fix a bug in the wrappers for the lex and yacc wrappers that are used for parsing Astropy units so that they work on pyc-only installations.
According to the Python module loading
flow chart, when evaluating
import foo
andfoo.py
is not found, Python then readsfoo.pyc
.One can take advantage of this fact to strip source files and leave only Python bytecode files for deployment in space-constrained execution environments such as AWS Lambda (see, for example, nasa-gcn/gcn.nasa.gov#2040).
Fix a bug in the wrappers for the lex and yacc wrappers that are used for parsing Astropy units so that they work on pyc-only installations.
Description
This pull request is to address ...
Fixes #