bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for "fildes". (GH-22620)

diff --git a/Modules/termios.c b/Modules/termios.c
index cc0d585..79b60ff 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -51,18 +51,6 @@
     return (termiosmodulestate *)state;
 }
 
-static int fdconv(PyObject* obj, void* p)
-{
-    int fd;
-
-    fd = PyObject_AsFileDescriptor(obj);
-    if (fd >= 0) {
-        *(int*)p = fd;
-        return 1;
-    }
-    return 0;
-}
-
 static struct PyModuleDef termiosmodule;
 
 PyDoc_STRVAR(termios_tcgetattr__doc__,
@@ -81,7 +69,7 @@
 {
     int fd;
     if (!PyArg_ParseTuple(args, "O&:tcgetattr",
-                          fdconv, (void*)&fd)) {
+                          _PyLong_FileDescriptor_Converter, (void*)&fd)) {
         return NULL;
     }
 
@@ -160,7 +148,7 @@
     int fd, when;
     PyObject *term;
     if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
-                          fdconv, &fd, &when, &term)) {
+                          _PyLong_FileDescriptor_Converter, &fd, &when, &term)) {
         return NULL;
     }
 
@@ -233,7 +221,7 @@
 {
     int fd, duration;
     if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
-                          fdconv, &fd, &duration)) {
+                          _PyLong_FileDescriptor_Converter, &fd, &duration)) {
         return NULL;
     }
 
@@ -255,7 +243,7 @@
 {
     int fd;
     if (!PyArg_ParseTuple(args, "O&:tcdrain",
-                          fdconv, &fd)) {
+                          _PyLong_FileDescriptor_Converter, &fd)) {
         return NULL;
     }
 
@@ -280,7 +268,7 @@
 {
     int fd, queue;
     if (!PyArg_ParseTuple(args, "O&i:tcflush",
-                          fdconv, &fd, &queue)) {
+                          _PyLong_FileDescriptor_Converter, &fd, &queue)) {
         return NULL;
     }
 
@@ -305,7 +293,7 @@
 {
     int fd, action;
     if (!PyArg_ParseTuple(args, "O&i:tcflow",
-                          fdconv, &fd, &action)) {
+                          _PyLong_FileDescriptor_Converter, &fd, &action)) {
         return NULL;
     }