GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support copy.replace() on AST nodes · Issue #121141 · python/cpython

Support copy.replace() on AST nodes #121141

New issue
Copy link
New issue
Copy link
Closed
Closed
Support copy.replace() on AST nodes#121141
Copy link
Assignees
JelleZijlstrapicnixz
Labels
type-featureA feature request or enhancementA feature request or enhancement

Description

@JelleZijlstra
JelleZijlstra
opened on Jun 28, 2024
Issue body actions

Feature 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

  • gh-121141: add support for copy.replace to AST nodes #121162
Reacted by Alex Waygood

Activity

  1. JelleZijlstra
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jun 28, 2024
  2. JelleZijlstra
    self-assigned this
    on Jun 28, 2024
  3. JelleZijlstra commented on Jun 28, 2024

    @JelleZijlstra
    JelleZijlstra
    on Jun 28, 2024
    MemberAuthor
    More actions

    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.

  4. picnixz commented on Jun 28, 2024

    @picnixz
    picnixz
    on Jun 28, 2024
    Member
    More actions

    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)

  5. JelleZijlstra commented on Jun 28, 2024

    @JelleZijlstra
    JelleZijlstra
    on Jun 28, 2024
    MemberAuthor
    More actions

    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.

  6. picnixz commented on Jun 28, 2024

    @picnixz
    picnixz
    on Jun 28, 2024
    Member
    More actions

    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).

  7. serhiy-storchaka commented on Jun 29, 2024

    @serhiy-storchaka
    serhiy-storchaka
    on Jun 29, 2024
    Member
    More actions

    I think that this would be useful.

  8. picnixz commented on Jun 29, 2024

    @picnixz
    picnixz
    on Jun 29, 2024
    Member
    More actions

    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
  9. sobolevn
    assigned
    picnixz
    on Jun 29, 2024
  10. JelleZijlstra
    added a commit that references this issue on Jul 4, 2024

    gh-121141: add support for `copy.replace` to AST nodes (#121162)

    9728ead
  11. JelleZijlstra commented on Jul 4, 2024

    @JelleZijlstra
    JelleZijlstra
    on Jul 4, 2024
    MemberAuthor
    More actions

    The implementation ended up pretty complicated, let's keep it for 3.14 only.

    Thanks @picnixz!

    Reacted by Bénédikt Tran
  12. JelleZijlstra
    closed this as completedon Jul 4, 2024
  13. estyxx
    added a commit that references this issue on Jul 17, 2024

    pythongh-121141: add support for `copy.replace` to AST nodes (python#…

    cefb3ed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra
  • @picnixz
    picnixz

Labels

type-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.