This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Incorrect signature of CodeType.replace()
Type: behavior Stage: patch review
Components: Argument Clinic, Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: larry, serhiy.storchaka, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2020-11-08 10:38 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 23199 open serhiy.storchaka, 2020-11-08 10:39
Messages (2)
msg380545 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-11-08 10:38
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.
msg380587 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-11-09 14:46
> 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).
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86457
2020-11-09 14:46:09vstinnersetmessages: + msg380587
2020-11-08 10:39:32serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request22099
2020-11-08 10:38:14serhiy.storchakacreate