[Python-checkins] python/dist/src/Lib posixpath.py,1.43,1.43.2.1

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
2002年6月18日 09:53:44 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv25579
Modified Files:
 Tag: release21-maint
	posixpath.py 
Log Message:
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.
Index: posixpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v
retrieving revision 1.43
retrieving revision 1.43.2.1
diff -C2 -d -r1.43 -r1.43.2.1
*** posixpath.py	16 Apr 2001 18:12:04 -0000	1.43
--- posixpath.py	18 Jun 2002 16:53:42 -0000	1.43.2.1
***************
*** 166,174 ****
 # This is false for dangling symbolic links.
 
 def exists(path):
 """Test whether a path exists. Returns false for broken symbolic links"""
 try:
 st = os.stat(path)
! except os.error:
 return 0
 return 1
--- 166,194 ----
 # 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, err:
! if err.errno in _errno_for_exists:
! return 1
 return 0
 return 1

AltStyle によって変換されたページ (->オリジナル) /