Skip to content

Commit 6353c21

Browse files
authored
gh-106320: Remove private _PyLong_FileDescriptor_Converter() (#108503)
Move the private _PyLong converter functions to the internal C API * _PyLong_FileDescriptor_Converter(): moved to pycore_fileutils.h * _PyLong_Size_t_Converter(): moved to pycore_long.h Argument Clinic now emits includes for pycore_fileutils.h and pycore_long.h when these functions are used.
1 parent 713afb8 commit 6353c21

File tree

13 files changed

+43
-10
lines changed

13 files changed

+43
-10
lines changed

Include/cpython/fileobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ typedef PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *);
1515
PyAPI_FUNC(PyObject *) PyFile_OpenCode(const char *utf8path);
1616
PyAPI_FUNC(PyObject *) PyFile_OpenCodeObject(PyObject *path);
1717
PyAPI_FUNC(int) PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction hook, void *userData);
18-
19-
PyAPI_FUNC(int) _PyLong_FileDescriptor_Converter(PyObject *, void *);

Include/cpython/longobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
6-
75
PyAPI_FUNC(PyObject*) PyLong_FromUnicodeObject(PyObject *u, int base);
86

97
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.

Include/internal/pycore_fileutils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ extern HRESULT PathCchSkipRoot(const wchar_t *pszPath, const wchar_t **ppszRootE
312312
# define _Py_END_SUPPRESS_IPH
313313
#endif /* _MSC_VER >= 1900 */
314314

315+
// Export for 'select' shared extension (Argument Clinic code)
316+
PyAPI_FUNC(int) _PyLong_FileDescriptor_Converter(PyObject *, void *);
317+
315318
#ifdef __cplusplus
316319
}
317320
#endif

Include/internal/pycore_long.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,21 @@ extern char* _PyLong_FormatBytesWriter(
187187
int alternate);
188188

189189
// Argument converters used by Argument Clinic
190+
191+
// Export for 'select' shared extension (Argument Clinic code)
190192
PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *);
193+
194+
// Export for '_testclinic' shared extension (Argument Clinic code)
191195
PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *);
196+
197+
// Export for '_blake2' shared extension (Argument Clinic code)
192198
PyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *);
199+
200+
// Export for '_blake2' shared extension (Argument Clinic code)
193201
PyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *);
194202

203+
// Export for '_testclinic' shared extension (Argument Clinic code)
204+
PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
195205

196206
/* Long value tag bits:
197207
* 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.

Modules/clinic/_winapi.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/fcntlmodule.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/posixmodule.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/selectmodule.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/termios.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/fcntlmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/* fcntl module */
22

3+
#ifndef Py_BUILD_CORE_BUILTIN
4+
# define Py_BUILD_CORE_MODULE 1
5+
#endif
6+
37
#include "Python.h"
48

59
#ifdef HAVE_SYS_FILE_H

Modules/termios.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/* termios.c -- POSIX terminal I/O module implementation. */
22

3+
#ifndef Py_BUILD_CORE_BUILTIN
4+
# define Py_BUILD_CORE_MODULE 1
5+
#endif
6+
37
#include "Python.h"
48

59
/* Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE

Tools/c-analyzer/c_parser/preprocessor/gcc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
'multibytecodec.h',
1313
'socketmodule.h',
1414

15-
# Argument Clinic ".c.h" files
15+
# Argument Clinic ".c.h" header files
1616
'_testclinic.c.h',
1717
'_testclinic_depr.c.h',
18+
'_winapi.c.h',
19+
'fcntlmodule.c.h',
1820
'overlapped.c.h',
1921
'posixmodule.c.h',
2022
'selectmodule.c.h',
2123
'sha3module.c.h',
24+
'termios.c.h',
2225
}
2326

2427
TOOL = 'gcc'

Tools/clinic/clinic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3835,6 +3835,10 @@ class size_t_converter(CConverter):
38353835
converter = '_PyLong_Size_t_Converter'
38363836
c_ignored_default = "0"
38373837

3838+
def converter_init(self, *, accept: TypeSet = {int, NoneType}) -> None:
3839+
self.add_include('pycore_long.h',
3840+
'_PyLong_Size_t_Converter()')
3841+
38383842
def parse_arg(self, argname: str, displayname: str) -> str | None:
38393843
if self.format_unit == 'n':
38403844
return """
@@ -3850,6 +3854,10 @@ class fildes_converter(CConverter):
38503854
type = 'int'
38513855
converter = '_PyLong_FileDescriptor_Converter'
38523856

3857+
def converter_init(self, *, accept: TypeSet = {int, NoneType}) -> None:
3858+
self.add_include('pycore_fileutils.h',
3859+
'_PyLong_FileDescriptor_Converter()')
3860+
38533861
def _parse_arg(self, argname: str, displayname: str) -> str | None:
38543862
return """
38553863
{paramname} = PyObject_AsFileDescriptor({argname});

0 commit comments

Comments
 (0)