]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106320: Remove private _PyLong converter functions (#108499)
authorVictor Stinner <vstinner@python.org>
Sat, 26 Aug 2023 00:24:27 +0000 (02:24 +0200)
committerGitHub <noreply@github.com>
Sat, 26 Aug 2023 00:24:27 +0000 (02:24 +0200)
Move these private functions to the internal C API (pycore_long.h):

* _PyLong_UnsignedInt_Converter()
* _PyLong_UnsignedLongLong_Converter()
* _PyLong_UnsignedLong_Converter()
* _PyLong_UnsignedShort_Converter()

Argument Clinic now emits #include "pycore_long.h" when these
functions are used.

14 files changed:
Include/cpython/longobject.h
Include/internal/pycore_long.h
Modules/_blake2/clinic/blake2b_impl.c.h
Modules/_blake2/clinic/blake2s_impl.c.h
Modules/clinic/_testclinic.c.h
Modules/clinic/_testclinic_depr.c.h
Modules/clinic/overlapped.c.h
Modules/clinic/posixmodule.c.h
Modules/clinic/selectmodule.c.h
Modules/clinic/sha3module.c.h
Modules/overlapped.c
PC/clinic/winreg.c.h
Tools/c-analyzer/c_parser/preprocessor/gcc.py
Tools/clinic/clinic.py

index 7401566636a1040ec6aac12c5813f444f29e0a33..c7ae1c2cd6bc6b9a26a68dc82676cbf73e39f954 100644 (file)
@@ -2,10 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *);
-PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *);
-PyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *);
-PyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *);
 PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
 
 PyAPI_FUNC(PyObject*) PyLong_FromUnicodeObject(PyObject *u, int base);
index a76494808bffdddfe301ad803fabf778366055ee..1dc5b7438c08793699ed9e9c09bd00a076ab7aca 100644 (file)
@@ -186,6 +186,13 @@ extern char* _PyLong_FormatBytesWriter(
     int base,
     int alternate);
 
+// Argument converters used by Argument Clinic
+PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *);
+PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *);
+PyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *);
+PyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *);
+
+
 /* Long value tag bits:
  * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
  * 2: Reserved for immortality bit
index 284cccf348703c74056a44f1aa94fc596a79ebb7..384e7142bcfda7663b86dad973f6376c08f35d4b 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedLong_Converter()
 
 PyDoc_STRVAR(py_blake2b_new__doc__,
 "blake2b(data=b\'\', /, *, digest_size=_blake2.blake2b.MAX_DIGEST_SIZE,\n"
@@ -276,4 +277,4 @@ _blake2_blake2b_hexdigest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))
 {
     return _blake2_blake2b_hexdigest_impl(self);
 }
-/*[clinic end generated code: output=76bbcf5f220511b9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=48128782266b7b8e input=a9049054013a1b77]*/
index 5b6af84bb242345fd74bce517681acce6b47abe9..d7a475277e054395d5de2a43df68dd7155a83c4c 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedLong_Converter()
 
 PyDoc_STRVAR(py_blake2s_new__doc__,
 "blake2s(data=b\'\', /, *, digest_size=_blake2.blake2s.MAX_DIGEST_SIZE,\n"
@@ -276,4 +277,4 @@ _blake2_blake2s_hexdigest(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored))
 {
     return _blake2_blake2s_hexdigest_impl(self);
 }
-/*[clinic end generated code: output=af69b321be0b4a77 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2188af9910a45497 input=a9049054013a1b77]*/
index d3a064605f0e417dee934235de4c79f30478c0a1..3c04c41599c6501d49116691d537354d60036436 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedShort_Converter()
 
 PyDoc_STRVAR(test_empty_function__doc__,
 "test_empty_function($module, /)\n"
@@ -3069,4 +3070,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=86396cbed6eb8b65 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=41f439aab0cb809d input=a9049054013a1b77]*/
index b8365bd559b4e7c05c7d4f3caa2026ee398fe7c2..71cb972b9513112f1be7796a9595266c6e1b6841 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedShort_Converter()
 
 PyDoc_STRVAR(depr_star_new__doc__,
 "DeprStarNew(a=None)\n"
@@ -2391,4 +2392,4 @@ depr_multi(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=ee8b1933e4bf4dc4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=22b59d92d517a8ec input=a9049054013a1b77]*/
index b6c5f79acb1f6b8b2f098a684762e794d517f1b9..100df2062d8efbaace80d324d798eeb816803a8c 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedLong_Converter()
 
 PyDoc_STRVAR(_overlapped_CreateIoCompletionPort__doc__,
 "CreateIoCompletionPort($module, handle, port, key, concurrency, /)\n"
@@ -1262,4 +1263,4 @@ exit:
 
     return return_value;
 }
-/*[clinic end generated code: output=9fbc01f706562dea input=a9049054013a1b77]*/
+/*[clinic end generated code: output=994ad727b827ff87 input=a9049054013a1b77]*/
index db82916b901f4b9bb932bd32f0a2c7ac3c89b8ec..ae3c1d60a919c1eb44adaf8f10d2d47776ebaa80 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedInt_Converter()
 
 PyDoc_STRVAR(os_stat__doc__,
 "stat($module, /, path, *, dir_fd=None, follow_symlinks=True)\n"
@@ -11990,4 +11991,4 @@ exit:
 #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
     #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
 #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
-/*[clinic end generated code: output=5e839ce21678ea66 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a08a47b52da6da0b input=a9049054013a1b77]*/
index bebcc24d67e3b8544d3b668657e8ed50ebbcdc08..f6b3ea388108ae45d6bdee29f57d72697188f333 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedShort_Converter()
 
 PyDoc_STRVAR(select_select__doc__,
 "select($module, rlist, wlist, xlist, timeout=None, /)\n"
@@ -1309,4 +1310,4 @@ exit:
 #ifndef SELECT_KQUEUE_CONTROL_METHODDEF
     #define SELECT_KQUEUE_CONTROL_METHODDEF
 #endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
-/*[clinic end generated code: output=7521d757ef9e63e8 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a19c29946a931dce input=a9049054013a1b77]*/
index 299803a3420bf634e04e2ef9ee5a4b0cc73c5c68..80fe3ed32c80dc82b50e1aab991d9e2161a9a9c3 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedLong_Converter()
 
 PyDoc_STRVAR(py_sha3_new__doc__,
 "sha3_224(data=b\'\', /, *, usedforsecurity=True)\n"
@@ -193,4 +194,4 @@ _sha3_shake_128_hexdigest(SHA3object *self, PyObject *arg)
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=907cb475f3dc9ee0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5188d9ae4af48c6d input=a9049054013a1b77]*/
index 271f6ce7e2d916368f69372e0bbb878299e9529b..34be3a495f3872f0b808251777ef1c2ba9c692cd 100644 (file)
@@ -7,8 +7,11 @@
 /* XXX check overflow and DWORD <-> Py_ssize_t conversions
    Check itemsize */
 
-#include "Python.h"
+#ifndef Py_BUILD_CORE_BUILTIN
+#  define Py_BUILD_CORE_MODULE 1
+#endif
 
+#include "Python.h"
 
 #define WINDOWS_LEAN_AND_MEAN
 #include <winsock2.h>
index a7401b9adc68809f55a2c9a3933b3c3c1d761da8..8cb8749498e3dfec268f099db5ad3918da68f3ca 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_long.h"           // _PyLong_UnsignedLong_Converter()
 
 #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES))
 
@@ -1788,4 +1789,4 @@ exit:
 #ifndef WINREG_QUERYREFLECTIONKEY_METHODDEF
     #define WINREG_QUERYREFLECTIONKEY_METHODDEF
 #endif /* !defined(WINREG_QUERYREFLECTIONKEY_METHODDEF) */
-/*[clinic end generated code: output=4d0ec3e43e1b28f4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=00343ee8da923da8 input=a9049054013a1b77]*/
index 415a2ba63dfe68757e6b0498efc296ab3c8cf8ed..62538f53c25a2e6037cd16125e44e4b4fc1bac37 100644 (file)
@@ -7,9 +7,18 @@ from . import common as _common
 # macro. Usually it's defined by the C file which includes it.
 # Other header files have a similar issue.
 NEED_BUILD_CORE = {
+    # Header ".h" files
     'cjkcodecs.h',
     'multibytecodec.h',
     'socketmodule.h',
+
+    # Argument Clinic ".c.h" files
+    '_testclinic.c.h',
+    '_testclinic_depr.c.h',
+    'overlapped.c.h',
+    'posixmodule.c.h',
+    'selectmodule.c.h',
+    'sha3module.c.h',
 }
 
 TOOL = 'gcc'
index a6974bd81e2d07f785ef639f333c31c51d69c1ad..c4304bb5b1270dd529630671ea92d42538d98b0c 100755 (executable)
@@ -3629,6 +3629,8 @@ class unsigned_short_converter(CConverter):
             self.format_unit = 'H'
         else:
             self.converter = '_PyLong_UnsignedShort_Converter'
+            self.add_include('pycore_long.h',
+                             '_PyLong_UnsignedShort_Converter()')
 
     def parse_arg(self, argname: str, displayname: str) -> str | None:
         if self.format_unit == 'H':
@@ -3690,6 +3692,8 @@ class unsigned_int_converter(CConverter):
             self.format_unit = 'I'
         else:
             self.converter = '_PyLong_UnsignedInt_Converter'
+            self.add_include('pycore_long.h',
+                             '_PyLong_UnsignedInt_Converter()')
 
     def parse_arg(self, argname: str, displayname: str) -> str | None:
         if self.format_unit == 'I':
@@ -3727,6 +3731,8 @@ class unsigned_long_converter(CConverter):
             self.format_unit = 'k'
         else:
             self.converter = '_PyLong_UnsignedLong_Converter'
+            self.add_include('pycore_long.h',
+                             '_PyLong_UnsignedLong_Converter()')
 
     def parse_arg(self, argname: str, displayname: str) -> str | None:
         if self.format_unit == 'k':
@@ -3766,6 +3772,8 @@ class unsigned_long_long_converter(CConverter):
             self.format_unit = 'K'
         else:
             self.converter = '_PyLong_UnsignedLongLong_Converter'
+            self.add_include('pycore_long.h',
+                             '_PyLong_UnsignedLongLong_Converter()')
 
     def parse_arg(self, argname: str, displayname: str) -> str | None:
         if self.format_unit == 'K':