-
-
Notifications
You must be signed in to change notification settings - Fork 64
Test failures with Python 3.8.0a2 #287
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
Mike Bayer has proposed a fix for this issue in the master branch: Add Constant to _ast_util https://gerrit.sqlalchemy.org/1172 |
I won't have pythron 3.8 in my CI environment just yet so if you can confirm the above patch works on your end as well (solves the problem here) that would be of value. |
Tests pass with the patch, thanks! |
Note that now we get Pylons/pyramid_mako#47:
|
So apparently, the Constant object can has different attributes. This mentions that:
But in Mako, the following attributes are used:
Now, the fix adds:
But that only fixes it for the tested case. In fact, for pyramid-mako, node.value fixes the tested case. I am not familiar with the _ast classes, but I think either there must be other attribute, or some kind of trial and error must be used instead. |
According to the Python code in that PR, I think that the proper thing to use is |
Ok, so this works: >>> import ast
>>> c = ast.Constant('a')
>>> c.value
'a'
>>> c.n
'a'
>>> c.s
'a' But this doesn't: >>> import _ast
>>> c = _ast.Constant('a')
>>> c.value
'a'
>>> c.n
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Constant' object has no attribute 'n'
>>> c.s
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Constant' object has no attribute 's' |
Since Python 3.8, class ast.Constant is used for all constants. Old classes ast.Num, ast.Str, ast.Bytes, ast.NameConstant and ast.Ellipsis are still available, but they will be removed in future Python releases. Constants have values, but not always ns. See sqlalchemy#287 (comment) See python/cpython#9445 Fixes Pylons/pyramid_mako#47
yeah but need a test. basically visit_Str, visit_Bytes, visit_Num are no longer called in 3.8. ill have one momentaily |
this is weird:
but in the test suite, same python, it's there - why?
|
this is in _ast.py....
Sooooooo....going to figure this out very shortly? moment |
oh. that's ast.py. um. this is weird |
Yep: #287 (comment) |
right, it's monkeypatching _ast.Constant... |
here is what's happening:
so there's really no way to test this, it's just, there it is, fix it....is Constant in 3.7 and earlier at all ? |
|
Seems to be in 3.6+. |
right but it has Constant.value in all of them and that's it.. |
in 3.7 they dont seem to be monkeypatrching n and s, likely because Constant wasn't used for num/string |
My wild guess is: If you import from _ast, you don't get any guarantees. If you import from ast, you get a somewhat backward compatible-ish behavior. |
Miro Hrončok has proposed a fix for this issue in the master branch: Use Constant.value, not Constant.n https://gerrit.sqlalchemy.org/1188 |
Those are the test failures I get with Python 3.8.0a2:
(I needed to apply #286 first.)
Full log
Most of the failures are some kind of
SyntaxError
:Seems like some values are missing in the rendered code, but I really have no idea.
The text was updated successfully, but these errors were encountered: