bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for "fildes". (GH-22620)
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 1c6ecaf..9b89448 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -223,6 +223,17 @@
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.