GeezerVison is showing github.com — Support copy.replace() on AST nodes · Issue #121141 · python/cpython
Support copy.replace() on AST nodes #121141DescriptionFeature or enhancement
Proposal:
I want this to work:
>>> 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
Links to previous discussion of this feature:
No response
Linked PRs
ActivityJelleZijlstra commented on 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.replace is new in 3.13. picnixz commented on 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 commented on 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 for copy.replace to be usable with more of the standard library. picnixz commented on Jun 28, 2024
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). serhiy-storchaka commented on Jun 29, 2024 I think that this would be useful. picnixz commented on 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. Reacted by Jelle Zijlstra and sobolevn JelleZijlstra commented on Jul 4, 2024 The implementation ended up pretty complicated, let's keep it for 3.14 only.
Thanks @picnixz!
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|