Commit 1c4fa4f
* gh-136681: Drop _PyArg_Parser for positional-only defining-class methods
A method that takes a defining class and whose other parameters are all
positional-only (e.g. decimal.Decimal.from_float) was routed through
Argument Clinic's generic keyword path: it emitted a static _PyArg_Parser,
an (empty) keyword tuple and an _PyArg_UnpackKeywords() call, even though
it accepts no keyword arguments.
Such methods now go through parse_pos_only(): the wrapper still uses the
mandatory METH_METHOD|METH_FASTCALL|METH_KEYWORDS convention (the only one
that delivers the defining class), but it rejects keywords with
_PyArg_NoKwnames() and reads positional arguments directly, with no
parser, keyword tuple or argsbuf.
This converts 135 methods across 19 clinic headers, removing the static
_PyArg_Parser, the keyword arrays/tuples and the per-call
_PyArg_UnpackKeywords() + parser_init() overhead for each.
_PyArg_NoKwnames() is now exported (PyAPI_FUNC) so generated code in
shared extension modules can use it, like _PyArg_NoKeywords().
Error messages for these methods now match ordinary positional-only
functions ("expected ... arguments" / "takes no keyword arguments"
instead of the _PyArg_UnpackKeywords phrasing); affected stdlib tests
are updated accordingly.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* gh-157407: Rename NEWS entry to the correct issue number
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent ca5277c commit 1c4fa4f
26 files changed
Lines changed: 643 additions & 2398 deletions
File tree
- Include/internal
- Lib/test
- test_sqlite3
- Misc/NEWS.d/next/Core_and_Builtins
- Modules
- _ctypes/clinic
- _decimal/clinic
- _io/clinic
- _sqlite/clinic
- cjkcodecs/clinic
- clinic
- Tools/clinic/libclinic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6032 | 6032 | | |
6033 | 6033 | | |
6034 | 6034 | | |
6035 | | - | |
6036 | | - | |
6037 | | - | |
6038 | | - | |
6039 | | - | |
6040 | | - | |
6041 | | - | |
6042 | | - | |
6043 | | - | |
6044 | | - | |
6045 | | - | |
6046 | | - | |
6047 | | - | |
6048 | 6035 | | |
6049 | 6036 | | |
6050 | 6037 | | |
6051 | | - | |
| 6038 | + | |
| 6039 | + | |
| 6040 | + | |
| 6041 | + | |
6052 | 6042 | | |
6053 | 6043 | | |
6054 | 6044 | | |
| |||
6062 | 6052 | | |
6063 | 6053 | | |
6064 | 6054 | | |
6065 | | - | |
| 6055 | + | |
6066 | 6056 | | |
6067 | 6057 | | |
6068 | 6058 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5114 | 5114 | | |
5115 | 5115 | | |
5116 | 5116 | | |
5117 | | - | |
| 5117 | + | |
5118 | 5118 | | |
5119 | 5119 | | |
5120 | 5120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | | - | |
| 453 | + | |
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
| 723 | + | |
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
| |||
767 | 767 | | |
768 | 768 | | |
769 | 769 | | |
770 | | - | |
| 770 | + | |
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments