Skip to content

Commit 89645cf

Browse files
committed
Explicitly remove the ctx attribute in copy_ast_without_context
Python 3.13.0b2+ defaults to Load when we don't pass ctx See python/cpython#118871
1 parent c1dd5b3 commit 89645cf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pure_eval/utils.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ def copy_ast_without_context(x):
184184
if field != 'ctx'
185185
if hasattr(x, field)
186186
}
187-
return type(x)(**kwargs)
187+
a = type(x)(**kwargs)
188+
if hasattr(a, 'ctx'):
189+
# Python 3.13.0b2+ defaults to Load when we don't pass ctx
190+
# https://github.com/python/cpython/pull/118871
191+
del a.ctx
192+
return a
188193
elif isinstance(x, list):
189194
return list(map(copy_ast_without_context, x))
190195
else:

0 commit comments

Comments
 (0)