-
Notifications
You must be signed in to change notification settings - Fork 3
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
AttributeError invoking macro in Python 3.9 / AST format change in 3.9 #20
Comments
Also - this package is really slick, thank you for such good documentation. The API feels very well thought out, |
Thank you for the kind words - and the bug report. :) Some of the credit belongs to the authors of As to the bug, it seems the Python devs have changed the AST format in 3.9. This actually happens quite often when there's a new minor release of Python. The Up to 3.8, the I don't yet have 3.9 myself, as I just upgraded to 3.8. But from your description of the problem, it seems the Could you run the following snippet and post here what it prints when run on 3.9? This would allow me to see the format, so I can add a version check and update the handling of from ast import parse
from mcpyrate import dump
tree = parse("foo[bar]") # simple subscripting with a single value
print(dump(tree, include_attributes=True))
tree = parse("foo[1:2]") # regular slicing
print(dump(tree, include_attributes=True))
tree = parse("foo[1:2, 3]") # advanced slicing
print(dump(tree, include_attributes=True)) For comparison, here's the output on 3.8 (the first one here is the format the current Module(body=[Expr(value=Subscript(value=Name(id='foo',
ctx=Load(),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=3),
slice=Index(value=Name(id='bar',
ctx=Load(),
lineno=1,
col_offset=4,
end_lineno=1,
end_col_offset=7)),
ctx=Load(),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=8),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=8)],
type_ignores=[])
Module(body=[Expr(value=Subscript(value=Name(id='foo',
ctx=Load(),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=3),
slice=Slice(lower=Constant(value=1,
kind=None,
lineno=1,
col_offset=4,
end_lineno=1,
end_col_offset=5),
upper=Constant(value=2,
kind=None,
lineno=1,
col_offset=6,
end_lineno=1,
end_col_offset=7),
step=None),
ctx=Load(),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=8),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=8)],
type_ignores=[])
Module(body=[Expr(value=Subscript(value=Name(id='foo',
ctx=Load(),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=3),
slice=ExtSlice(dims=[Slice(lower=Constant(value=1,
kind=None,
lineno=1,
col_offset=4,
end_lineno=1,
end_col_offset=5),
upper=Constant(value=2,
kind=None,
lineno=1,
col_offset=6,
end_lineno=1,
end_col_offset=7),
step=None),
Index(value=Constant(value=3,
kind=None,
lineno=1,
col_offset=9,
end_lineno=1,
end_col_offset=10))]),
ctx=Load(),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=11),
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=11)],
type_ignores=[] |
That's really annoying that there isn't a stable API. Your snippet prints the following on 3.9.1:
|
I agree the lack of a stable API for the AST is annoying, but on the other hand, this iterative improvement will produce a better end result in the long run (not having to worry about backward compatibility). So Also Thanks for testing! Now I know what to update. |
Note to self, to find the places that need to be fixed, grep for:
|
Should work now. Could you pull from git and re-test on 3.9? Please note there may be other undocumented AST format changes. If so, post here, so I'll know what else to fix. :) EDIT: unclear wording: as in, please tell me if you find something else in |
Thanks for fixing this. Tests passing on 3.9! |
For information: original BPO regarding the dropping of |
I get the following error:
when invoking a small macro:
like this:
There are a couple places in this file that do
.value
, not just here, and they also give this error on 3.9. The example works correctly on 3.7.The text was updated successfully, but these errors were encountered: