Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b1e73b

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 5df2269 commit 6b1e73b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pure_eval/utils.py

Lines changed: 6 additions & 1 deletion
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)