import stat
import genericpath
from genericpath import *
-from nt import _getfileinformation
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
def sameopenfile(f1, f2):
"""Test whether two file objects reference the same file"""
- return _getfileinformation(f1) == _getfileinformation(f2)
+ try:
+ from nt import _getfileinformation
+ return _getfileinformation(f1) == _getfileinformation(f2)
+ except ImportError:
+ # On other operating systems, return True if the file descriptors
+ # are the same.
+ return f1 == f2
import ntpath
import os
+import sys
from test.support import TestFailed
from test import support, test_genericpath
from tempfile import TemporaryFile
self.assertTrue(ntpath.sameopenfile(tf1.fileno(), tf1.fileno()))
# Make sure different files are really different
self.assertFalse(ntpath.sameopenfile(tf1.fileno(), tf2.fileno()))
- # Make sure invalid values don't cause issues
- with self.assertRaises(ValueError):
- # Invalid file descriptors shouldn't display assert
- # dialogs (#4804)
- ntpath.sameopenfile(-1, -1)
+ # Make sure invalid values don't cause issues on win32
+ if sys.platform == "win32":
+ with self.assertRaises(ValueError):
+ # Invalid file descriptors shouldn't display assert
+ # dialogs (#4804)
+ ntpath.sameopenfile(-1, -1)
class NtCommonTest(test_genericpath.CommonTest):