[New-bugs-announce] [issue20431] Should posix functions that accept fd also accept objects with .fileno()?

Larry Hastings report at bugs.python.org
Wed Jan 29 04:48:20 CET 2014


New submission from Larry Hastings:

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?

----------
messages: 209613
nosy: larry
priority: low
severity: normal
stage: needs patch
status: open
title: Should posix functions that accept fd also accept objects with .fileno()?
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20431>
_______________________________________


More information about the New-bugs-announce mailing list