Skip to content

Commit

Permalink
Explicitly remove the ctx attribute in copy_ast_without_context
Browse files Browse the repository at this point in the history
Python 3.13.0b2+ defaults to Load when we don't pass ctx
See python/cpython#118871
  • Loading branch information
hroncok committed Jun 9, 2024
1 parent c1dd5b3 commit 89645cf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pure_eval/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ def copy_ast_without_context(x):
if field != 'ctx'
if hasattr(x, field)
}
return type(x)(**kwargs)
a = type(x)(**kwargs)
if hasattr(a, 'ctx'):
# Python 3.13.0b2+ defaults to Load when we don't pass ctx
# https://github.com/python/cpython/pull/118871
del a.ctx
return a
elif isinstance(x, list):
return list(map(copy_ast_without_context, x))
else:
Expand Down

0 comments on commit 89645cf

Please sign in to comment.