You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> n=ast.Name(id="x")
>>> copy.replace(n, id="y")
Traceback (most recent call last):
File "<python-input-4>", line 1, in <module>
copy.replace(n, id="y")
~~~~~~~~~~~~^^^^^^^^^^^
File "/Users/jelle/py/cpython/Lib/copy.py", line 293, in replace
raise TypeError(f"replace() does not support {cls.__name__} objects")
TypeError: replace() does not support Name objects
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
I am interested in this one but not today (it's midnight now). However, when do you want this feature to be ready? (if you can give me an ETA, I can tell you if I have enough time)
I don't have a specific timeframe in mind except that I'd like it at least in 3.14, which gives us a little less than a year of leeway.
For 3.13, @Yhg1s (as release manager) and @serhiy-storchaka (as author of copy.replace) what do you think of adding this feature? It's late but it would be nice for copy.replace to be usable with more of the standard library.
which gives us a little less than a year of leeway.
I was more worried of whether you wanted it by the end of the week or the next week... One year or less if more than enough for me I think (if the feature is to be included).
Activity
JelleZijlstra commentedon Jun 28, 2024
I plan to work on this at some point, but if someone else is interested in it earlier, feel free to pick it up.
This could just possibly still go in 3.13, as
copy.replaceis new in 3.13.picnixz commentedon Jun 28, 2024
I am interested in this one but not today (it's midnight now). However, when do you want this feature to be ready? (if you can give me an ETA, I can tell you if I have enough time)
JelleZijlstra commentedon Jun 28, 2024
I don't have a specific timeframe in mind except that I'd like it at least in 3.14, which gives us a little less than a year of leeway.
For 3.13, @Yhg1s (as release manager) and @serhiy-storchaka (as author of
copy.replace) what do you think of adding this feature? It's late but it would be nice forcopy.replaceto be usable with more of the standard library.picnixz commentedon Jun 28, 2024
I was more worried of whether you wanted it by the end of the week or the next week... One year or less if more than enough for me I think (if the feature is to be included).
serhiy-storchaka commentedon Jun 29, 2024
I think that this would be useful.
picnixz commentedon Jun 29, 2024
I'll work on that one after my thesis defense (next week). @JelleZijlstra would you like to assign the task to me please?
EDIT: Thank you Nikita!
EDIT 2: well I managed to do it today.
gh-121141: add support for `copy.replace` to AST nodes (#121162)
JelleZijlstra commentedon Jul 4, 2024
The implementation ended up pretty complicated, let's keep it for 3.14 only.
Thanks @picnixz!
pythongh-121141: add support for `copy.replace` to AST nodes (python#…
pythongh-121141: add support for `copy.replace` to AST nodes (python#…