From 3ab1798f24d3caba36611b37a05a75542e5e2107 Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Tue, 18 Jun 2002 16:53:42 +0000 Subject: [PATCH] Add a special case code to deal with unexpected large files. # 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 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 6bf40f8336e5..db0d3dd2daef 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -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 -- 2.47.3