From 9975cc5008c795e069ce11e2dbed2110cc12e74e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 9 Oct 2020 23:00:45 +0300 Subject: bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for "fildes". (GH-22620) --- Objects/fileobject.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Objects/fileobject.c') diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 1c6ecaf82c..9b89448006 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -223,6 +223,17 @@ PyObject_AsFileDescriptor(PyObject *o) return fd; } +int +_PyLong_FileDescriptor_Converter(PyObject *o, void *ptr) +{ + int fd = PyObject_AsFileDescriptor(o); + if (fd == -1) { + return 0; + } + *(int *)ptr = fd; + return 1; +} + /* ** Py_UniversalNewlineFgets is an fgets variation that understands ** all of \r, \n and \r\n conventions. -- cgit v1.2.1