]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add a special case code to deal with unexpected large files.
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 18 Jun 2002 16:53:42 +0000 (16:53 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 18 Jun 2002 16:53:42 +0000 (16:53 +0000)
# On a Linux with large file support (LFS) using a Python without LFS,
# stat() will raise EOVERFLOW.  This unambiguously indicates that the
# file exists because it only occurs when the size of the file can't
# find into the stat struct.

This change is only needed for Python 2.1, because LFS is
automatically configured starting with Python 2.2.

Lib/posixpath.py

index 6bf40f8336e56488739b0501fa08a009ef64bce0..db0d3dd2daef6a1a8cf50c8362d75b90ad75738d 100644 (file)
@@ -165,11 +165,31 @@ def islink(path):
 # Does a path exist?
 # This is false for dangling symbolic links.
 
+# In some cases, an error from stat() means the file does exist.
+
+# On a Linux with large file support (LFS) using a Python without LFS,
+# stat() will raise EOVERFLOW.  This unambiguously indicates that the
+# file exists because it only occurs when the size of the file can't
+# find into the stat struct.
+
+_errno_for_exists = []
+
+try:
+    import errno
+except ImportError:
+    pass
+else:
+    EOVERFLOW = getattr(errno, "EOVERFLOW", None)
+    if EOVERFLOW is not None:
+        _errno_for_exists.append(EOVERFLOW)
+
 def exists(path):
     """Test whether a path exists.  Returns false for broken symbolic links"""
     try:
         st = os.stat(path)
-    except os.error:
+    except os.error, err:
+        if err.errno in _errno_for_exists:
+            return 1
         return 0
     return 1