-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Adapt the Python 3.7 AST changes #2870
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
Adapt the Python 3.7 AST changes #2870
Conversation
i think we need to add python 3.7 to travis to get the needed results the failures shown are known and will be fixed |
testing/test_assertrewrite.py
Outdated
assert isinstance(m.body[0], ast.Expr) | ||
assert isinstance(m.body[0].value, ast.Str) | ||
for imp in m.body[1:3]: | ||
if sys.version_info < (3, 7): |
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 trying to understand this, why remove the docstring from the beginning of the AST in the test? If it should not be there, then perhaps we should assert
what we expect to be there in >=3.7
?
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.
Module docstring is now (in 3.7) a part of Module node, it's not in the body. So I check if there's docstring expression in Python prior to 3.7 and then remove it so the following body items have the same indexes on both Pythons. This way, for example, m.body[0:2]
is a slice of imports.
I didn't like this approach. So I split this test in 3: one without docstrings that works on both versions, one with docstrings that's skipped prior to 3.7, and one with docstrings for versions after 3.7. This looked quite ugly as well to me, so I reverted to this variant.
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.
Module docstring is now (in 3.7) a part of Module node, it's not in the body. So I check if there's docstring expression in Python prior to 3.7 and then remove it so the following body items have the same indexes on both Pythons. This way, for example, m.body[0:2] is a slice of imports.
@Perlence thanks for the detailed explanation, everything is clear to me now.
We already run Python 3.7 on Travis, that's the "nightly" build.
Indeed. I would like to understand better the change to the tests first though. I propose we make a serious effort of promoting the "nightly" build from Allowed Failures to normal mode only when Python 3.7 reaches beta status. |
We're thinking change again in 3.7b3. In this time, docstring will be moved from attribute to special AST node named
3.6: 3.7b2: 3.7b3?: Of course, We want feedback from AST users. Please post your comment on this issue or Python-Dev mailing list. |
@methane thanks for the ping! |
NOTE: fixing/reverting of `doc = getattr(mod, "docstring", None)` was missed in 3153740 (pytest-dev#4723). It was added initially in pytest-dev#2870, but never made it into a final Python release. Basically reverts / revisits based on changes introduced in 734c435.
NOTE: fixing/reverting of `doc = getattr(mod, "docstring", None)` was missed in 3153740 (pytest-dev#4723). It was added initially in pytest-dev#2870, but never made it into a final Python release. Basically reverts / revisits based on changes introduced in 734c435. Adjusts a7dfc6f (#243).
Some bytecode tests are expected to fail in Python 3.7.0a1 and 3.7.0a2, because there was a bug that prevented some environ vars from having effect. It was fixed in python/cpython@d7ac061.
Resolves #2818.