]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-108635: Make parameters of some implementations of special methods positional...
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 29 Aug 2023 14:55:56 +0000 (17:55 +0300)
committerGitHub <noreply@github.com>
Tue, 29 Aug 2023 14:55:56 +0000 (17:55 +0300)
Include/internal/pycore_global_objects_fini_generated.h
Include/internal/pycore_global_strings.h
Include/internal/pycore_runtime_init_generated.h
Include/internal/pycore_unicodeobject_generated.h
Objects/clinic/typevarobject.c.h
Objects/typevarobject.c
PC/clinic/winreg.c.h
PC/winreg.c

index 2f930babf6aad406a021714576d0cc2f3f5a50f2..d2b6058362ca23ff11b2d1cd077dac37e83d229e 100644 (file)
@@ -789,7 +789,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
     _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(aggregate_class));
     _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(alias));
     _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(append));
-    _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arg));
     _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(argdefs));
     _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(args));
     _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arguments));
index 5a0cd1a02ba5615bda55c6d56a5bd3811f80691c..169528d6eb1feeaa0479129ee26c8add4c27e14e 100644 (file)
@@ -278,7 +278,6 @@ struct _Py_global_strings {
         STRUCT_FOR_ID(aggregate_class)
         STRUCT_FOR_ID(alias)
         STRUCT_FOR_ID(append)
-        STRUCT_FOR_ID(arg)
         STRUCT_FOR_ID(argdefs)
         STRUCT_FOR_ID(args)
         STRUCT_FOR_ID(arguments)
index 694a409fbf4f47987a06ff7f1b539328531f4df2..ccfedf9b32d2a0082baf142fb3b983cdcd03722c 100644 (file)
@@ -787,7 +787,6 @@ extern "C" {
     INIT_ID(aggregate_class), \
     INIT_ID(alias), \
     INIT_ID(append), \
-    INIT_ID(arg), \
     INIT_ID(argdefs), \
     INIT_ID(args), \
     INIT_ID(arguments), \
index 841eb78701127102cf22613e434de6edc0ebff8e..ff7aeba1de96bfd49a2073148f3703e8fcbee828 100644 (file)
@@ -675,9 +675,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
     string = &_Py_ID(append);
     assert(_PyUnicode_CheckConsistency(string, 1));
     _PyUnicode_InternInPlace(interp, &string);
-    string = &_Py_ID(arg);
-    assert(_PyUnicode_CheckConsistency(string, 1));
-    _PyUnicode_InternInPlace(interp, &string);
     string = &_Py_ID(argdefs);
     assert(_PyUnicode_CheckConsistency(string, 1));
     _PyUnicode_InternInPlace(interp, &string);
index 54189b98446814b8441fa92bcac55442cd412b50..5d12be5361cd2fc16c78f76f97c49ceca0ba27af 100644 (file)
@@ -110,58 +110,12 @@ exit:
 }
 
 PyDoc_STRVAR(typevar_typing_subst__doc__,
-"__typing_subst__($self, /, arg)\n"
+"__typing_subst__($self, arg, /)\n"
 "--\n"
 "\n");
 
 #define TYPEVAR_TYPING_SUBST_METHODDEF    \
-    {"__typing_subst__", _PyCFunction_CAST(typevar_typing_subst), METH_FASTCALL|METH_KEYWORDS, typevar_typing_subst__doc__},
-
-static PyObject *
-typevar_typing_subst_impl(typevarobject *self, PyObject *arg);
-
-static PyObject *
-typevar_typing_subst(typevarobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
-{
-    PyObject *return_value = NULL;
-    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
-
-    #define NUM_KEYWORDS 1
-    static struct {
-        PyGC_Head _this_is_not_used;
-        PyObject_VAR_HEAD
-        PyObject *ob_item[NUM_KEYWORDS];
-    } _kwtuple = {
-        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
-        .ob_item = { &_Py_ID(arg), },
-    };
-    #undef NUM_KEYWORDS
-    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
-
-    #else  // !Py_BUILD_CORE
-    #  define KWTUPLE NULL
-    #endif  // !Py_BUILD_CORE
-
-    static const char * const _keywords[] = {"arg", NULL};
-    static _PyArg_Parser _parser = {
-        .keywords = _keywords,
-        .fname = "__typing_subst__",
-        .kwtuple = KWTUPLE,
-    };
-    #undef KWTUPLE
-    PyObject *argsbuf[1];
-    PyObject *arg;
-
-    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
-    if (!args) {
-        goto exit;
-    }
-    arg = args[0];
-    return_value = typevar_typing_subst_impl(self, arg);
-
-exit:
-    return return_value;
-}
+    {"__typing_subst__", (PyCFunction)typevar_typing_subst, METH_O, typevar_typing_subst__doc__},
 
 PyDoc_STRVAR(typevar_reduce__doc__,
 "__reduce__($self, /)\n"
@@ -386,106 +340,33 @@ exit:
 }
 
 PyDoc_STRVAR(paramspec_typing_subst__doc__,
-"__typing_subst__($self, /, arg)\n"
+"__typing_subst__($self, arg, /)\n"
 "--\n"
 "\n");
 
 #define PARAMSPEC_TYPING_SUBST_METHODDEF    \
-    {"__typing_subst__", _PyCFunction_CAST(paramspec_typing_subst), METH_FASTCALL|METH_KEYWORDS, paramspec_typing_subst__doc__},
-
-static PyObject *
-paramspec_typing_subst_impl(paramspecobject *self, PyObject *arg);
-
-static PyObject *
-paramspec_typing_subst(paramspecobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
-{
-    PyObject *return_value = NULL;
-    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
-
-    #define NUM_KEYWORDS 1
-    static struct {
-        PyGC_Head _this_is_not_used;
-        PyObject_VAR_HEAD
-        PyObject *ob_item[NUM_KEYWORDS];
-    } _kwtuple = {
-        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
-        .ob_item = { &_Py_ID(arg), },
-    };
-    #undef NUM_KEYWORDS
-    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
-
-    #else  // !Py_BUILD_CORE
-    #  define KWTUPLE NULL
-    #endif  // !Py_BUILD_CORE
-
-    static const char * const _keywords[] = {"arg", NULL};
-    static _PyArg_Parser _parser = {
-        .keywords = _keywords,
-        .fname = "__typing_subst__",
-        .kwtuple = KWTUPLE,
-    };
-    #undef KWTUPLE
-    PyObject *argsbuf[1];
-    PyObject *arg;
-
-    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
-    if (!args) {
-        goto exit;
-    }
-    arg = args[0];
-    return_value = paramspec_typing_subst_impl(self, arg);
-
-exit:
-    return return_value;
-}
+    {"__typing_subst__", (PyCFunction)paramspec_typing_subst, METH_O, paramspec_typing_subst__doc__},
 
 PyDoc_STRVAR(paramspec_typing_prepare_subst__doc__,
-"__typing_prepare_subst__($self, /, alias, args)\n"
+"__typing_prepare_subst__($self, alias, args, /)\n"
 "--\n"
 "\n");
 
 #define PARAMSPEC_TYPING_PREPARE_SUBST_METHODDEF    \
-    {"__typing_prepare_subst__", _PyCFunction_CAST(paramspec_typing_prepare_subst), METH_FASTCALL|METH_KEYWORDS, paramspec_typing_prepare_subst__doc__},
+    {"__typing_prepare_subst__", _PyCFunction_CAST(paramspec_typing_prepare_subst), METH_FASTCALL, paramspec_typing_prepare_subst__doc__},
 
 static PyObject *
 paramspec_typing_prepare_subst_impl(paramspecobject *self, PyObject *alias,
                                     PyObject *args);
 
 static PyObject *
-paramspec_typing_prepare_subst(paramspecobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+paramspec_typing_prepare_subst(paramspecobject *self, PyObject *const *args, Py_ssize_t nargs)
 {
     PyObject *return_value = NULL;
-    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
-
-    #define NUM_KEYWORDS 2
-    static struct {
-        PyGC_Head _this_is_not_used;
-        PyObject_VAR_HEAD
-        PyObject *ob_item[NUM_KEYWORDS];
-    } _kwtuple = {
-        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
-        .ob_item = { &_Py_ID(alias), &_Py_ID(args), },
-    };
-    #undef NUM_KEYWORDS
-    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
-
-    #else  // !Py_BUILD_CORE
-    #  define KWTUPLE NULL
-    #endif  // !Py_BUILD_CORE
-
-    static const char * const _keywords[] = {"alias", "args", NULL};
-    static _PyArg_Parser _parser = {
-        .keywords = _keywords,
-        .fname = "__typing_prepare_subst__",
-        .kwtuple = KWTUPLE,
-    };
-    #undef KWTUPLE
-    PyObject *argsbuf[2];
     PyObject *alias;
     PyObject *__clinic_args;
 
-    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
-    if (!args) {
+    if (!_PyArg_CheckPositional("__typing_prepare_subst__", nargs, 2, 2)) {
         goto exit;
     }
     alias = args[0];
@@ -572,106 +453,33 @@ exit:
 }
 
 PyDoc_STRVAR(typevartuple_typing_subst__doc__,
-"__typing_subst__($self, /, arg)\n"
+"__typing_subst__($self, arg, /)\n"
 "--\n"
 "\n");
 
 #define TYPEVARTUPLE_TYPING_SUBST_METHODDEF    \
-    {"__typing_subst__", _PyCFunction_CAST(typevartuple_typing_subst), METH_FASTCALL|METH_KEYWORDS, typevartuple_typing_subst__doc__},
-
-static PyObject *
-typevartuple_typing_subst_impl(typevartupleobject *self, PyObject *arg);
-
-static PyObject *
-typevartuple_typing_subst(typevartupleobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
-{
-    PyObject *return_value = NULL;
-    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
-
-    #define NUM_KEYWORDS 1
-    static struct {
-        PyGC_Head _this_is_not_used;
-        PyObject_VAR_HEAD
-        PyObject *ob_item[NUM_KEYWORDS];
-    } _kwtuple = {
-        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
-        .ob_item = { &_Py_ID(arg), },
-    };
-    #undef NUM_KEYWORDS
-    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
-
-    #else  // !Py_BUILD_CORE
-    #  define KWTUPLE NULL
-    #endif  // !Py_BUILD_CORE
-
-    static const char * const _keywords[] = {"arg", NULL};
-    static _PyArg_Parser _parser = {
-        .keywords = _keywords,
-        .fname = "__typing_subst__",
-        .kwtuple = KWTUPLE,
-    };
-    #undef KWTUPLE
-    PyObject *argsbuf[1];
-    PyObject *arg;
-
-    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
-    if (!args) {
-        goto exit;
-    }
-    arg = args[0];
-    return_value = typevartuple_typing_subst_impl(self, arg);
-
-exit:
-    return return_value;
-}
+    {"__typing_subst__", (PyCFunction)typevartuple_typing_subst, METH_O, typevartuple_typing_subst__doc__},
 
 PyDoc_STRVAR(typevartuple_typing_prepare_subst__doc__,
-"__typing_prepare_subst__($self, /, alias, args)\n"
+"__typing_prepare_subst__($self, alias, args, /)\n"
 "--\n"
 "\n");
 
 #define TYPEVARTUPLE_TYPING_PREPARE_SUBST_METHODDEF    \
-    {"__typing_prepare_subst__", _PyCFunction_CAST(typevartuple_typing_prepare_subst), METH_FASTCALL|METH_KEYWORDS, typevartuple_typing_prepare_subst__doc__},
+    {"__typing_prepare_subst__", _PyCFunction_CAST(typevartuple_typing_prepare_subst), METH_FASTCALL, typevartuple_typing_prepare_subst__doc__},
 
 static PyObject *
 typevartuple_typing_prepare_subst_impl(typevartupleobject *self,
                                        PyObject *alias, PyObject *args);
 
 static PyObject *
-typevartuple_typing_prepare_subst(typevartupleobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+typevartuple_typing_prepare_subst(typevartupleobject *self, PyObject *const *args, Py_ssize_t nargs)
 {
     PyObject *return_value = NULL;
-    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
-
-    #define NUM_KEYWORDS 2
-    static struct {
-        PyGC_Head _this_is_not_used;
-        PyObject_VAR_HEAD
-        PyObject *ob_item[NUM_KEYWORDS];
-    } _kwtuple = {
-        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
-        .ob_item = { &_Py_ID(alias), &_Py_ID(args), },
-    };
-    #undef NUM_KEYWORDS
-    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
-
-    #else  // !Py_BUILD_CORE
-    #  define KWTUPLE NULL
-    #endif  // !Py_BUILD_CORE
-
-    static const char * const _keywords[] = {"alias", "args", NULL};
-    static _PyArg_Parser _parser = {
-        .keywords = _keywords,
-        .fname = "__typing_prepare_subst__",
-        .kwtuple = KWTUPLE,
-    };
-    #undef KWTUPLE
-    PyObject *argsbuf[2];
     PyObject *alias;
     PyObject *__clinic_args;
 
-    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
-    if (!args) {
+    if (!_PyArg_CheckPositional("__typing_prepare_subst__", nargs, 2, 2)) {
         goto exit;
     }
     alias = args[0];
@@ -783,4 +591,4 @@ skip_optional_kwonly:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=807bcd30ebd10ac3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d614edf64f28e346 input=a9049054013a1b77]*/
index ef1803d0fd5526ce2eb2a020db100b92e75998c4..3adae3e14c9103c2da07fe8b50ea61a209e50d54 100644 (file)
@@ -402,12 +402,13 @@ typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
 typevar.__typing_subst__ as typevar_typing_subst
 
     arg: object
+    /
 
 [clinic start generated code]*/
 
 static PyObject *
-typevar_typing_subst_impl(typevarobject *self, PyObject *arg)
-/*[clinic end generated code: output=c76ced134ed8f4e1 input=6b70a4bb2da838de]*/
+typevar_typing_subst(typevarobject *self, PyObject *arg)
+/*[clinic end generated code: output=0773735e8ce18968 input=9e87b57f0fc59b92]*/
 {
     PyObject *args[2] = {(PyObject *)self, arg};
     PyObject *result = call_typing_func_object("_typevar_subst", args, 2);
@@ -884,12 +885,13 @@ paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound,
 paramspec.__typing_subst__ as paramspec_typing_subst
 
     arg: object
+    /
 
 [clinic start generated code]*/
 
 static PyObject *
-paramspec_typing_subst_impl(paramspecobject *self, PyObject *arg)
-/*[clinic end generated code: output=803e1ade3f13b57d input=4e0005d24023e896]*/
+paramspec_typing_subst(paramspecobject *self, PyObject *arg)
+/*[clinic end generated code: output=4c5b4aaada1c5814 input=2d5b5e3d4a717189]*/
 {
     PyObject *args[2] = {(PyObject *)self, arg};
     PyObject *result = call_typing_func_object("_paramspec_subst", args, 2);
@@ -901,13 +903,14 @@ paramspec.__typing_prepare_subst__ as paramspec_typing_prepare_subst
 
     alias: object
     args: object
+    /
 
 [clinic start generated code]*/
 
 static PyObject *
 paramspec_typing_prepare_subst_impl(paramspecobject *self, PyObject *alias,
                                     PyObject *args)
-/*[clinic end generated code: output=95449d630a2adb9a input=4375e2ffcb2ad635]*/
+/*[clinic end generated code: output=95449d630a2adb9a input=6df6f9fef3e150da]*/
 {
     PyObject *args_array[3] = {(PyObject *)self, alias, args};
     PyObject *result = call_typing_func_object(
@@ -1106,12 +1109,13 @@ typevartuple_impl(PyTypeObject *type, PyObject *name)
 typevartuple.__typing_subst__ as typevartuple_typing_subst
 
     arg: object
+    /
 
 [clinic start generated code]*/
 
 static PyObject *
-typevartuple_typing_subst_impl(typevartupleobject *self, PyObject *arg)
-/*[clinic end generated code: output=814316519441cd76 input=670c4e0a36e5d8c0]*/
+typevartuple_typing_subst(typevartupleobject *self, PyObject *arg)
+/*[clinic end generated code: output=237054c6d7484eea input=3fcf2dfd9eee7945]*/
 {
     PyErr_SetString(PyExc_TypeError, "Substitution of bare TypeVarTuple is not supported");
     return NULL;
@@ -1122,13 +1126,14 @@ typevartuple.__typing_prepare_subst__ as typevartuple_typing_prepare_subst
 
     alias: object
     args: object
+    /
 
 [clinic start generated code]*/
 
 static PyObject *
 typevartuple_typing_prepare_subst_impl(typevartupleobject *self,
                                        PyObject *alias, PyObject *args)
-/*[clinic end generated code: output=ff999bc5b02036c1 input=a211b05f2eeb4306]*/
+/*[clinic end generated code: output=ff999bc5b02036c1 input=685b149b0fc47556]*/
 {
     PyObject *args_array[3] = {(PyObject *)self, alias, args};
     PyObject *result = call_typing_func_object(
index 8cb8749498e3dfec268f099db5ad3918da68f3ca..6e23929c185caf457e369f957287ae176b98ccd2 100644 (file)
@@ -93,53 +93,26 @@ winreg_HKEYType___enter__(PyHKEYObject *self, PyObject *Py_UNUSED(ignored))
 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
 
 PyDoc_STRVAR(winreg_HKEYType___exit____doc__,
-"__exit__($self, /, exc_type, exc_value, traceback)\n"
+"__exit__($self, exc_type, exc_value, traceback, /)\n"
 "--\n"
 "\n");
 
 #define WINREG_HKEYTYPE___EXIT___METHODDEF    \
-    {"__exit__", _PyCFunction_CAST(winreg_HKEYType___exit__), METH_FASTCALL|METH_KEYWORDS, winreg_HKEYType___exit____doc__},
+    {"__exit__", _PyCFunction_CAST(winreg_HKEYType___exit__), METH_FASTCALL, winreg_HKEYType___exit____doc__},
 
 static PyObject *
 winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type,
                               PyObject *exc_value, PyObject *traceback);
 
 static PyObject *
-winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *const *args, Py_ssize_t nargs)
 {
     PyObject *return_value = NULL;
-    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
-
-    #define NUM_KEYWORDS 3
-    static struct {
-        PyGC_Head _this_is_not_used;
-        PyObject_VAR_HEAD
-        PyObject *ob_item[NUM_KEYWORDS];
-    } _kwtuple = {
-        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
-        .ob_item = { &_Py_ID(exc_type), &_Py_ID(exc_value), &_Py_ID(traceback), },
-    };
-    #undef NUM_KEYWORDS
-    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
-
-    #else  // !Py_BUILD_CORE
-    #  define KWTUPLE NULL
-    #endif  // !Py_BUILD_CORE
-
-    static const char * const _keywords[] = {"exc_type", "exc_value", "traceback", NULL};
-    static _PyArg_Parser _parser = {
-        .keywords = _keywords,
-        .fname = "__exit__",
-        .kwtuple = KWTUPLE,
-    };
-    #undef KWTUPLE
-    PyObject *argsbuf[3];
     PyObject *exc_type;
     PyObject *exc_value;
     PyObject *traceback;
 
-    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
-    if (!args) {
+    if (!_PyArg_CheckPositional("__exit__", nargs, 3, 3)) {
         goto exit;
     }
     exc_type = args[0];
@@ -1789,4 +1762,4 @@ exit:
 #ifndef WINREG_QUERYREFLECTIONKEY_METHODDEF
     #define WINREG_QUERYREFLECTIONKEY_METHODDEF
 #endif /* !defined(WINREG_QUERYREFLECTIONKEY_METHODDEF) */
-/*[clinic end generated code: output=00343ee8da923da8 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2431b1b06b148722 input=a9049054013a1b77]*/
index ee47a3fd40fc8660df2628e27f6291ce48081f53..767127d34cab1b1504b66882cf4b898a10eeb9cf 100644 (file)
@@ -324,12 +324,14 @@ winreg.HKEYType.__exit__
     exc_type: object
     exc_value: object
     traceback: object
+    /
+
 [clinic start generated code]*/
 
 static PyObject *
 winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type,
                               PyObject *exc_value, PyObject *traceback)
-/*[clinic end generated code: output=923ebe7389e6a263 input=fb32489ee92403c7]*/
+/*[clinic end generated code: output=923ebe7389e6a263 input=1eac83cd06962689]*/
 {
     winreg_state *st = _PyType_GetModuleState(Py_TYPE(self));
     assert(st != NULL);