aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-10-09 23:00:45 +0300
committerGitHub <noreply@github.com>2020-10-09 23:00:45 +0300
commit9975cc5008c795e069ce11e2dbed2110cc12e74e (patch)
tree87aca48f943cd04f0a3defe5f2666438efa959fa /Objects
parentbpo-39481: Fix duplicate SimpleQueue type in test_genericalias.py (GH-22619) (diff)
downloadcpython-9975cc5008c795e069ce11e2dbed2110cc12e74e.tar.gz
cpython-9975cc5008c795e069ce11e2dbed2110cc12e74e.tar.bz2
cpython-9975cc5008c795e069ce11e2dbed2110cc12e74e.zip
bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for "fildes". (GH-22620)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 1c6ecaf82c2..9b89448006e 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.