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: Allow keyword arguments in code.__new__
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: pxeger, rhettinger
Priority: normal Keywords:

Created on 2021-08-05 19:55 by pxeger, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg399034 - (view) Author: Patrick Reader (pxeger) * Date: 2021-08-05 19:55
Per bpo-41263, code.__new__ now uses Argument Clinic. However, it still has a / marker which prevents the use of keyword arguments (https://github.com/python/cpython/pull/21426/files#diff-6f869eb8beb7cbe4bc6817584b99ad567f88962fa67f7beca25d009dc401234dR465).

It seems entirely unnecessary to have this, so could it be removed to allow easier construction of code objects from user code, or is it there for some specific reason?

I can do a PR - it's a 1 line change (+ clinic output changes) (+ tests?).

I don't imagine backwards-compatibility is a concern here given it's implementation-specific and basically private.

Note that prior to that fix, keyword arguments were allowed in the constructor but completely ignored.
msg399422 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-08-11 23:16
Generally, construction time is faster if the arguments are positional only.  

Also, this isn't a method that people typically call directly — it is only quasi-public because the layout of the codestring is implementation dependent and changes every now and then.   Given that it is essentially private, there is no benefit to exposing keyword argument calls.

Thanks for the suggestion, but I don't think it makes things better for users.
History
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89008
2021-11-20 06:45:23pxegersetnosy: - terry.reedy
2021-11-20 01:38:23terry.reedysetpull_requests: - pull_request27890
2021-11-20 01:36:38terry.reedysetnosy: + terry.reedy

pull_requests: + pull_request27890
2021-08-11 23:16:42rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg399422

resolution: rejected
stage: resolved
2021-08-05 19:55:55pxegercreate