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()
|