-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
compile() doesn't work on ImportFrom with level=None #57645
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
Comments
The documentation for ast says that arguments that are marked with a '?' in the abstract grammar are optional and can therefore be None. Module(body=[ImportFrom(module='time', names=[alias(name='sleep', asname=None), alias(name='time', asname=None)], level=None, lineno=0, col_offset=0)]) Traceback (most recent call last):
File "g0.py", line 423, in <module>
p.main()
File "g0.py", line 65, in main
self.reproduce("g1.pyc")
File "g0.py", line 85, in reproduce
co = self.generate_bytecode(st, genome)
File "g0.py", line 243, in generate_bytecode
co = compile(st, id, "exec")
ValueError: invalid integer value: �������� So, I tried to set level=0: and everything worked fine. BTW: The unprintable bytes in the error message are: |
Here is a patch for the bad error message (PyBytes_AS_BYTES after PyObject_Repr, bah) |
LGTM. |
New changeset ffcdfc534942 by Amaury Forgeot d'Arc in branch '3.2': New changeset 470f7d7c57ce by Amaury Forgeot d'Arc in branch '3.2': |
I fixed the bogus error message, but "level=None" is still not allowed, whereas the docs promise that optional values can be None. |
Does this apply to 2.7 as well? I believe msg148146 is due to a commit message typo. |
level=None is now allowed: https://hg.python.org/cpython/file/default/Python/Python-ast.c#l5224 (see line 5224 to 5232) I converted the example in msg147972 to a Python script. test_bad_integer is still useful as it uses the required 'lineno' field. I will also commit issue13436.py as a test case. |
New changeset 59638baee25e by Berker Peksag in branch 'default': |
This doesn't happen naturally, but is allowed by the ASDL and compiler. We don't want to change ASDL for backward compatibility reasons (python#57645, python#92987)
…GH-92992) This doesn't happen naturally, but is allowed by the ASDL and compiler. We don't want to change ASDL for backward compatibility reasons (pythonGH-57645, pythonGH-92987) (cherry picked from commit 200c9a8) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
…ythonGH-92992) This doesn't happen naturally, but is allowed by the ASDL and compiler. We don't want to change ASDL for backward compatibility reasons (pythonGH-57645, pythonGH-92987) (cherry picked from commit 200c9a8) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
) (GH-96593) This doesn't happen naturally, but is allowed by the ASDL and compiler. We don't want to change ASDL for backward compatibility reasons (GH-57645, GH-92987) (cherry picked from commit 200c9a8) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: