Skip to content

Incorrect signature of CodeType.replace() #86457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
serhiy-storchaka opened this issue Nov 8, 2020 · 2 comments
Closed

Incorrect signature of CodeType.replace() #86457

serhiy-storchaka opened this issue Nov 8, 2020 · 2 comments
Labels
3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir topic-argument-clinic type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Nov 8, 2020

BPO 42291
Nosy @vstinner, @larryhastings, @serhiy-storchaka, @1st1
PRs
  • gh-86457: Fix signature for code.replace(). #23199
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-11-08.10:38:14.301>
    labels = ['type-bug', '3.8', '3.9', '3.10', 'library', 'expert-argument-clinic']
    title = 'Incorrect signature of CodeType.replace()'
    updated_at = <Date 2020-11-09.14:46:09.424>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-11-09.14:46:09.424>
    actor = 'vstinner'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'Argument Clinic']
    creation = <Date 2020-11-08.10:38:14.301>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42291
    keywords = ['patch']
    message_count = 2.0
    messages = ['380545', '380587']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'larry', 'serhiy.storchaka', 'yselivanov']
    pr_nums = ['23199']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue42291'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    Linked PRs

    @serhiy-storchaka
    Copy link
    Member Author

    Currently the signature of types.CodeType.replace() is

    replace(self, /, *, co_argcount=-1, co_posonlyargcount=-1, co_kwonlyargcount=-1, co_nlocals=-1, co_stacksize=-1, co_flags=-1, co_firstlineno=-1, co_code=None, co_consts=None, co_names=None, co_varnames=None, co_freevars=None, co_cellvars=None, co_filename=None, co_name=None, co_lnotab=None)

    But -1 and None are incorrect values for many parameters, and even if they would be correct, they are not default values. By default, if you do not specify some argument, the value of the corresponding attribute would not be changed.

    Argument Clinic and the inspect module do not support this case.

    @serhiy-storchaka serhiy-storchaka added 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir topic-argument-clinic type-bug An unexpected behavior, bug, or error labels Nov 8, 2020
    @vstinner
    Copy link
    Member

    vstinner commented Nov 9, 2020

    Argument Clinic and the inspect module do not support this case.

    That's why I used -1 and None.

    But -1 and None are incorrect values for many parameters, and even if they would be correct, they are not default values. By default, if you do not specify some argument, the value of the corresponding attribute would not be changed.

    If you consider that this issue matters, you may hack the code to accept None as if no parameter was passed (pass NULL).

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Dec 7, 2022
    serhiy-storchaka added a commit that referenced this issue Aug 7, 2023
    Also add support of @text_signature in Argument Clinic.
    serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Aug 7, 2023
    Also add support of @text_signature in Argument Clinic..
    (cherry picked from commit 0e6e32f)
    
    Co-authored-by: Serhiy Storchaka <[email protected]>
    serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Aug 7, 2023
    Also add support of @text_signature in Argument Clinic..
    (cherry picked from commit 0e6e32f)
    
    Co-authored-by: Serhiy Storchaka <[email protected]>
    erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Aug 7, 2023
    serhiy-storchaka added a commit that referenced this issue Aug 9, 2023
    Also add support of @text_signature in Argument Clinic.
    (cherry picked from commit 0e6e32f)
    erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Aug 9, 2023
    …irective (python#107747)
    
    (cherry picked from commit a9aeb99)
    
    Co-authored-by: Alex Waygood <[email protected]>
    erlend-aasland added a commit that referenced this issue Aug 9, 2023
    Yhg1s pushed a commit that referenced this issue Aug 16, 2023
    * [3.12] gh-86457: Fix signature for code.replace() (GH-23199)
    
    Also add support of @text_signature in Argument Clinic..
    (cherry picked from commit 0e6e32f)
    
    Co-authored-by: Serhiy Storchaka <[email protected]>
    
    * Update 2023-08-07-16-30-48.gh-issue-95065.-im4R5.rst
    AA-Turner pushed a commit to AA-Turner/devguide that referenced this issue Sep 13, 2023
    erlend-aasland added a commit to python/devguide that referenced this issue Sep 26, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir topic-argument-clinic type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants