diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 582f5c7bf05471..adef8388b1afe6 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -464,3 +464,11 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. Otherwise, the return value is undefined. +.. c:function:: int PyLong_FileDescriptor_Converter(PyObject *p, void *ptr) + + Convert a Python object to a file descript (C ``int`` type). + Set *\*ptr* and return ``1`` on success. + Set an exception and return ``0`` on error. + + It can be used with the ``O&`` format when :ref:`parsing arguments + `. diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat index 25629b4da053da..411657678d074b 100644 --- a/Doc/data/stable_abi.dat +++ b/Doc/data/stable_abi.dat @@ -363,6 +363,7 @@ function,PyLong_AsUnsignedLongLong,3.2,, function,PyLong_AsUnsignedLongLongMask,3.2,, function,PyLong_AsUnsignedLongMask,3.2,, function,PyLong_AsVoidPtr,3.2,, +function,PyLong_FileDescriptor_Converter,3.13,, function,PyLong_FromDouble,3.2,, function,PyLong_FromLong,3.2,, function,PyLong_FromLongLong,3.2,, diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 51939909000960..b99d95575e171b 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -1645,6 +1645,10 @@ New Features between native integer types and Python :class:`int` objects. (Contributed by Steve Dower in :gh:`111140`.) +* Add :c:func:`PyLong_FileDescriptor_Converter` function: convert a Python + object to a file descriptor. Function added the limited C API. + (Contributed by Victor Stinner in :gh:`116646`.) + Porting to Python 3.13 ---------------------- diff --git a/Include/cpython/fileutils.h b/Include/cpython/fileutils.h index b386ad107bde1f..723b4cba1047b8 100644 --- a/Include/cpython/fileutils.h +++ b/Include/cpython/fileutils.h @@ -6,3 +6,6 @@ PyAPI_FUNC(FILE*) _Py_fopen_obj( PyObject *path, const char *mode); + +// Alias kept for backward compatibility with Python 3.12 +#define _PyLong_FileDescriptor_Converter PyLong_FileDescriptor_Converter diff --git a/Include/fileutils.h b/Include/fileutils.h index 1509198e45f0ca..24feba288076d6 100644 --- a/Include/fileutils.h +++ b/Include/fileutils.h @@ -50,6 +50,12 @@ PyAPI_FUNC(char*) Py_EncodeLocale( size_t *error_pos); #endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 +// PyArg converter to convert a Python int objet to a C int. +// Return 1 on success. Set an exception and return 0 on error. +PyAPI_FUNC(int) PyLong_FileDescriptor_Converter(PyObject *, void *); +#endif + #ifndef Py_LIMITED_API # define Py_CPYTHON_FILEUTILS_H # include "cpython/fileutils.h" diff --git a/Include/internal/pycore_fileutils.h b/Include/internal/pycore_fileutils.h index 5c55282fa39e6f..4359d215c38e22 100644 --- a/Include/internal/pycore_fileutils.h +++ b/Include/internal/pycore_fileutils.h @@ -312,9 +312,6 @@ extern HRESULT PathCchSkipRoot(const wchar_t *pszPath, const wchar_t **ppszRootE # define _Py_END_SUPPRESS_IPH #endif /* _MSC_VER >= 1900 */ -// Export for 'select' shared extension (Argument Clinic code) -PyAPI_FUNC(int) _PyLong_FileDescriptor_Converter(PyObject *, void *); - // Export for test_peg_generator PyAPI_FUNC(char*) _Py_UniversalNewlineFgetsWithSize(char *, int, FILE*, PyObject *, size_t*); diff --git a/Lib/test/test_stable_abi_ctypes.py b/Lib/test/test_stable_abi_ctypes.py index 8bd373976426ef..8412362359b516 100644 --- a/Lib/test/test_stable_abi_ctypes.py +++ b/Lib/test/test_stable_abi_ctypes.py @@ -396,6 +396,7 @@ def test_windows_feature_macros(self): "PyLong_AsUnsignedLongLongMask", "PyLong_AsUnsignedLongMask", "PyLong_AsVoidPtr", + "PyLong_FileDescriptor_Converter", "PyLong_FromDouble", "PyLong_FromLong", "PyLong_FromLongLong", diff --git a/Misc/NEWS.d/next/C API/2024-03-12-13-56-14.gh-issue-116646.sW27CQ.rst b/Misc/NEWS.d/next/C API/2024-03-12-13-56-14.gh-issue-116646.sW27CQ.rst new file mode 100644 index 00000000000000..bc7b0abb309950 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2024-03-12-13-56-14.gh-issue-116646.sW27CQ.rst @@ -0,0 +1,2 @@ +Add PyLong_FileDescriptor_Converter function: convert a Python object to a +file descriptor. Function added the limited C API. Patch by Victor Stinner. diff --git a/Misc/stable_abi.toml b/Misc/stable_abi.toml index ca7cf02961571e..2632b5c43c3272 100644 --- a/Misc/stable_abi.toml +++ b/Misc/stable_abi.toml @@ -2496,3 +2496,5 @@ [typedef.PyCFunctionFastWithKeywords] added = '3.13' # "abi-only" since 3.10. (Same story as PyCFunctionFast.) +[function.PyLong_FileDescriptor_Converter] + added = '3.13' diff --git a/Modules/clinic/fcntlmodule.c.h b/Modules/clinic/fcntlmodule.c.h index 5dc2fc068d0f7e..69dfc9f40d767b 100644 --- a/Modules/clinic/fcntlmodule.c.h +++ b/Modules/clinic/fcntlmodule.c.h @@ -2,7 +2,6 @@ preserve [clinic start generated code]*/ -#include "pycore_fileutils.h" // _PyLong_FileDescriptor_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() PyDoc_STRVAR(fcntl_fcntl__doc__, @@ -38,7 +37,7 @@ fcntl_fcntl(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("fcntl", nargs, 2, 3)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } code = PyLong_AsInt(args[1]); @@ -108,7 +107,7 @@ fcntl_ioctl(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("ioctl", nargs, 2, 4)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } code = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); @@ -158,7 +157,7 @@ fcntl_flock(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("flock", nargs, 2, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } code = PyLong_AsInt(args[1]); @@ -218,7 +217,7 @@ fcntl_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("lockf", nargs, 2, 5)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } code = PyLong_AsInt(args[1]); @@ -246,4 +245,4 @@ fcntl_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=732e33ba92042031 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e6c003d9d31b3ef4 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index b7338d138e91ce..98477592ba1b3e 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -7,7 +7,6 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_abstract.h" // _PyNumber_Index() -#include "pycore_fileutils.h" // _PyLong_FileDescriptor_Converter() #include "pycore_long.h" // _PyLong_UnsignedInt_Converter() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() @@ -481,7 +480,7 @@ os_fchdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } return_value = os_fchdir_impl(module, fd); @@ -1024,7 +1023,7 @@ os_fsync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } return_value = os_fsync_impl(module, fd); @@ -1107,7 +1106,7 @@ os_fdatasync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } return_value = os_fdatasync_impl(module, fd); @@ -4531,7 +4530,7 @@ os_grantpt(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = os_grantpt_impl(module, fd); @@ -4567,7 +4566,7 @@ os_unlockpt(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = os_unlockpt_impl(module, fd); @@ -4604,7 +4603,7 @@ os_ptsname(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = os_ptsname_impl(module, fd); @@ -4664,7 +4663,7 @@ os_login_tty(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = os_login_tty_impl(module, fd); @@ -5881,7 +5880,7 @@ os_setns(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (!noptargs) { @@ -6322,7 +6321,7 @@ os_timerfd_settime(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (!noptargs) { @@ -6435,7 +6434,7 @@ os_timerfd_settime_ns(PyObject *module, PyObject *const *args, Py_ssize_t nargs, if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (!noptargs) { @@ -6495,7 +6494,7 @@ os_timerfd_gettime(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = os_timerfd_gettime_impl(module, fd); @@ -6529,7 +6528,7 @@ os_timerfd_gettime_ns(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = os_timerfd_gettime_ns_impl(module, fd); @@ -9691,7 +9690,7 @@ os_fpathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("fpathconf", nargs, 2, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (!conv_path_confname(args[1], &name)) { @@ -10834,7 +10833,7 @@ os_eventfd_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } return_value = os_eventfd_read_impl(module, fd); @@ -10896,7 +10895,7 @@ os_eventfd_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (!_PyLong_UnsignedLongLong_Converter(args[1], &value)) { @@ -12588,4 +12587,4 @@ os__supports_virtual_terminal(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF #define OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF #endif /* !defined(OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF) */ -/*[clinic end generated code: output=2965306970f31c5d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b0eb25df41f36dc7 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h index 67e76d4c89f59a..c576a64a0c98a3 100644 --- a/Modules/clinic/selectmodule.c.h +++ b/Modules/clinic/selectmodule.c.h @@ -6,7 +6,6 @@ preserve # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif -#include "pycore_fileutils.h" // _PyLong_FileDescriptor_Converter() #include "pycore_long.h" // _PyLong_UnsignedShort_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() @@ -100,7 +99,7 @@ select_poll_register(pollObject *self, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("register", nargs, 1, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (nargs < 2) { @@ -148,7 +147,7 @@ select_poll_modify(pollObject *self, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("modify", nargs, 2, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) { @@ -182,7 +181,7 @@ select_poll_unregister(pollObject *self, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = select_poll_unregister_impl(self, fd); @@ -268,7 +267,7 @@ select_devpoll_register(devpollObject *self, PyObject *const *args, Py_ssize_t n if (!_PyArg_CheckPositional("register", nargs, 1, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (nargs < 2) { @@ -318,7 +317,7 @@ select_devpoll_modify(devpollObject *self, PyObject *const *args, Py_ssize_t nar if (!_PyArg_CheckPositional("modify", nargs, 1, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (nargs < 2) { @@ -356,7 +355,7 @@ select_devpoll_unregister(devpollObject *self, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = select_devpoll_unregister_impl(self, fd); @@ -730,7 +729,7 @@ select_epoll_register(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t na if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } if (!noptargs) { @@ -806,7 +805,7 @@ select_epoll_modify(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t narg if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } eventmask = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); @@ -874,7 +873,7 @@ select_epoll_unregister(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t if (!args) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } return_value = select_epoll_unregister_impl(self, fd); @@ -1311,4 +1310,4 @@ select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize #ifndef SELECT_KQUEUE_CONTROL_METHODDEF #define SELECT_KQUEUE_CONTROL_METHODDEF #endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ -/*[clinic end generated code: output=4c2dcb31cb17c2c6 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6da67b9741f7ca95 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/termios.c.h b/Modules/clinic/termios.c.h index 1c340681e5862f..8ebec7b6384f10 100644 --- a/Modules/clinic/termios.c.h +++ b/Modules/clinic/termios.c.h @@ -2,7 +2,6 @@ preserve [clinic start generated code]*/ -#include "pycore_fileutils.h" // _PyLong_FileDescriptor_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() PyDoc_STRVAR(termios_tcgetattr__doc__, @@ -30,7 +29,7 @@ termios_tcgetattr(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = termios_tcgetattr_impl(module, fd); @@ -69,7 +68,7 @@ termios_tcsetattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("tcsetattr", nargs, 3, 3)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } when = PyLong_AsInt(args[1]); @@ -108,7 +107,7 @@ termios_tcsendbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("tcsendbreak", nargs, 2, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } duration = PyLong_AsInt(args[1]); @@ -139,7 +138,7 @@ termios_tcdrain(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = termios_tcdrain_impl(module, fd); @@ -174,7 +173,7 @@ termios_tcflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("tcflush", nargs, 2, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } queue = PyLong_AsInt(args[1]); @@ -213,7 +212,7 @@ termios_tcflow(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("tcflow", nargs, 2, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } action = PyLong_AsInt(args[1]); @@ -246,7 +245,7 @@ termios_tcgetwinsize(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int fd; - if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { + if (!PyLong_FileDescriptor_Converter(arg, &fd)) { goto exit; } return_value = termios_tcgetwinsize_impl(module, fd); @@ -280,7 +279,7 @@ termios_tcsetwinsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("tcsetwinsize", nargs, 2, 2)) { goto exit; } - if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { + if (!PyLong_FileDescriptor_Converter(args[0], &fd)) { goto exit; } winsz = args[1]; @@ -289,4 +288,4 @@ termios_tcsetwinsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=f31382658135c774 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a691628e3243b8ed input=a9049054013a1b77]*/ diff --git a/Objects/fileobject.c b/Objects/fileobject.c index e30ab952dff571..b6792e56088542 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -221,7 +221,7 @@ PyObject_AsFileDescriptor(PyObject *o) } int -_PyLong_FileDescriptor_Converter(PyObject *o, void *ptr) +PyLong_FileDescriptor_Converter(PyObject *o, void *ptr) { int fd = PyObject_AsFileDescriptor(o); if (fd == -1) { diff --git a/PC/python3dll.c b/PC/python3dll.c index aa6bfe2c4022db..f49aea470240b1 100755 --- a/PC/python3dll.c +++ b/PC/python3dll.c @@ -346,6 +346,7 @@ EXPORT_FUNC(PyLong_AsUnsignedLongLong) EXPORT_FUNC(PyLong_AsUnsignedLongLongMask) EXPORT_FUNC(PyLong_AsUnsignedLongMask) EXPORT_FUNC(PyLong_AsVoidPtr) +EXPORT_FUNC(PyLong_FileDescriptor_Converter) EXPORT_FUNC(PyLong_FromDouble) EXPORT_FUNC(PyLong_FromLong) EXPORT_FUNC(PyLong_FromLongLong) diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 893f4cc12ed084..642ac763df9579 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -3844,11 +3844,7 @@ def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> st class fildes_converter(CConverter): type = 'int' - converter = '_PyLong_FileDescriptor_Converter' - - def converter_init(self, *, accept: TypeSet = {int, NoneType}) -> None: - self.add_include('pycore_fileutils.h', - '_PyLong_FileDescriptor_Converter()') + converter = 'PyLong_FileDescriptor_Converter' def _parse_arg(self, argname: str, displayname: str) -> str | None: return self.format_code("""