[ python-Bugs-1002398 ] os.path.sameopenfile documentation wrong.
SourceForge.net
noreply at sourceforge.net
Tue Aug 3 05:35:35 CEST 2004
Bugs item #1002398, was opened at 2004-08-02 23:35
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1002398&group_id=5470
Category: Documentation
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Fincher (jemfinch)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.sameopenfile documentation wrong.
Initial Comment:
At http://docs.python.org/lib/module-os.path.html it very clearly
states this:
sameopenfile(fp1, fp2)
Return True if the file objects fp1 and fp2 refer to the same file.
The two file objects may represent different file descriptors.
Availability: Macintosh, Unix.
However, on my OSX box, the source to posixpath.py clearly says
otherwise:
def sameopenfile(fp1, fp2):
"""Test whether two open file objects reference the same file"""
s1 = os.fstat(fp1)
s2 = os.fstat(fp2)
return samestat(s1, s2)
I.e., sameopenfile accepts two integer filenos, not two file objects.
Running it gives this exception:
File "/System/Library/Frameworks/Python.framework/Versions/
2.3/lib/python2.3/site-packages/supybot/plugins/Tail.py", line 77,
in samefile
return os.path.sameopenfile(fd1, fd2)
File "/System/Library/Frameworks/Python.framework/Versions/
2.3/lib/python2.3/posixpath.py", line 220, in sameopenfile
s1 = os.fstat(fp1)
TypeError: an integer is required
Perhaps the (much more useful) documented behavior can be
retained, and two if statements added to the definition of
sameopenfile:
if not isinstance(fp1, int): fp1 = fp1.fileno()
if not isinstance(fp2, int): fp2 = fp2.fileno()
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1002398&group_id=5470
More information about the Python-bugs-list
mailing list