Patch to fix new alias attributes in Python 3.10
- From @brathis - Seems to be ok for Python 3.9
This commit is contained in:
parent
c213a02543
commit
a5052b49e4
|
|
@ -101,7 +101,8 @@ def _do_wrap_class_register(tree, mod, base_class):
|
|||
# Function call to it passing reg_name and name
|
||||
do_register = Expr(value=Call(func=attr, args=[Str(s=reg_name), Name(id=name, ctx=Load())], keywords=[]))
|
||||
# Create the import
|
||||
do_import = ImportFrom(module=mod, names=[alias(name=base_class, asname=None)], level=1)
|
||||
do_import = ImportFrom(module=mod, names=[alias(name=base_class, asname=None, lineno=tree.lineno,
|
||||
col_offset=tree.col_offset)], level=1)
|
||||
return [do_import, tree, do_register]
|
||||
# Just in case somebody applies it to anything other than a class
|
||||
return tree
|
||||
|
|
|
|||
|
|
@ -649,8 +649,12 @@ def find_macros(tree, *, filename, reload=False, self_module=None, transform=Tru
|
|||
else:
|
||||
# Remove all names to prevent macros being used as regular run-time objects.
|
||||
# Always use an absolute import, for the unhygienic expose API guarantee.
|
||||
tree.body[index] = copy_location(Import(names=[alias(name=module_absname, asname=None)]),
|
||||
statement)
|
||||
tree.body[index] = copy_location(Import(names=[
|
||||
alias(name=module_absname,
|
||||
asname=None,
|
||||
lineno=getattr(statement, 'lineno', 0),
|
||||
col_offset=getattr(statement, 'col_offset', 0))]),
|
||||
statement)
|
||||
for index in reversed(stmts_to_delete):
|
||||
tree.body.pop(index)
|
||||
return bindings
|
||||
|
|
|
|||
Loading…
Reference in New Issue