This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: fstat doesn't accept an object with "fileno" method
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: anacrolix, benjamin.peterson, eric.smith, petri.lehtinen, pitrou, stutzbach
Priority: low Keywords:

Created on 2011-11-02 04:04 by anacrolix, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg146823 - (view) Author: Matt Joiner (anacrolix) Date: 2011-11-02 04:04
os.fstat doesn't not accept an object with the fileno() method.

Probably a bunch of other similar functions will not either.

In some parts of the standard library it's common practice to call PyObject_AsFileDescriptor on fd-wrapping arguments.

http://hg.python.org/cpython/file/d877d7f3b679/Modules/posixmodule.c#l7319
http://hg.python.org/cpython/file/d877d7f3b679/Objects/fileobject.c#l196
msg146831 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-11-02 07:14
This is a request for new functionality, so marking as a feature request for 3.3. If implemented, the change should be applied to many other functions, in the os module at least.

I'm not sure whether this is very useful, though. The fstat(f.fileno()) idiom doesn't require that much writing and makes it explicit that we're operating on an underlying file descriptor. Furthermore, funtions in the os module are low-level and map very closely to the underlying C API.
msg146869 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-11-02 19:01
If I understand it correctly, this change request is to change os.fstat(obj) (and probably other functions) to call obj.fileno(), instead of the caller doing that?

If so, -1. Keep os.fstat() as a thin wrapper around fstat.
msg147034 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-11-04 20:48
Closing as wontfix.
History
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57530
2011-11-04 20:48:26petri.lehtinensetmessages: + msg147034
2011-11-04 20:48:02petri.lehtinensetstatus: open -> closed
resolution: wont fix
stage: resolved
2011-11-02 19:01:57eric.smithsetnosy: + eric.smith
messages: + msg146869
2011-11-02 13:00:04benjamin.petersonsetpriority: normal -> low
2011-11-02 07:14:37petri.lehtinensetversions: - Python 3.2
nosy: + pitrou, stutzbach, benjamin.peterson, petri.lehtinen

messages: + msg146831

type: behavior -> enhancement
2011-11-02 04:04:11anacrolixcreate