Repository navigation
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 |
mhvk
left a comment
There was a problem hiding this comment.
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 |
| t.value = int(t.value) | ||
| return t | ||
|
|
||
| def t_error(t): |
There was a problem hiding this comment.
Is this being required an indication of anything more serious?
There was a problem hiding this comment.
I don't think so. Just that PLY lacks a sensible default for t_error if the lexer does not provide one.
|
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. |
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 fooandfoo.pyis 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 #