Issue 20431: Should posix functions that accept fd also accept objects with .fileno()? (original) (raw)
While working on posixmodule.c today I noticed that some functions that accept file descriptors call PyObject_AsFileDescriptor(). This function accepts ints. It also accepts objects that expose a .fileno() attribute, calling that attribute and using the integer it returns.
There are other functions in posixmodule.c that accept file descriptors that call _fd_converter(), which just looks for an int with a proper value.
I figure it should be one way or the other. Should everything in posix that accepts file descriptor ints accept the .fileno() convention too?