[Python-checkins] cpython (2.7): Solaris' /dev/null is a symlink. The device test now uses stat instead of lstat

christian.heimes python-checkins at python.org
Sun Jun 23 16:27:09 CEST 2013


http://hg.python.org/cpython/rev/8f0adcb66633
changeset:   84278:8f0adcb66633
branch:      2.7
parent:      84272:d7e22acb2315
user:        Christian Heimes <christian at cheimes.de>
date:        Sun Jun 23 16:27:01 2013 +0200
summary:
  Solaris' /dev/null is a symlink. The device test now uses stat instead of lstat to compensate
for symlinks.

files:
  Lib/test/test_stat.py |  12 ++++++++----
  1 files changed, 8 insertions(+), 4 deletions(-)


diff --git a/Lib/test/test_stat.py b/Lib/test/test_stat.py
--- a/Lib/test/test_stat.py
+++ b/Lib/test/test_stat.py
@@ -58,8 +58,12 @@
                 pass
     tearDown = setUp
 
-    def get_mode(self, fname=TESTFN):
-        return os.lstat(fname).st_mode
+    def get_mode(self, fname=TESTFN, lstat=True):
+        if lstat:
+            st_mode = os.lstat(fname).st_mode
+        else:
+            st_mode = os.stat(fname).st_mode
+        return st_mode
 
     def assertS_IS(self, name, mode):
         # test format, lstrip is for S_IFIFO
@@ -136,12 +140,12 @@
     @unittest.skipUnless(os.name == 'posix', 'requires Posix')
     def test_devices(self):
         if os.path.exists(os.devnull):
-            st_mode = self.get_mode(os.devnull)
+            st_mode = self.get_mode(os.devnull, lstat=False)
             self.assertS_IS("CHR", st_mode)
         # Linux block devices, BSD has no block devices anymore
         for blockdev in ("/dev/sda", "/dev/hda"):
             if os.path.exists(blockdev):
-                st_mode = self.get_mode(blockdev)
+                st_mode = self.get_mode(blockdev, lstat=False)
                 self.assertS_IS("BLK", st_mode)
                 break
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list