[Python-checkins] CVS: python/dist/src/Lib ntpath.py,1.44,1.45
Mark Hammond
mhammond@users.sourceforge.net
Wed, 16 Jan 2002 16:44:28 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv24934
Modified Files:
ntpath.py
Log Message:
Allow abspath to still do something sensisble if the nt module can not be imported.
Index: ntpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** ntpath.py 2001/11/05 21:25:02 1.44
--- ntpath.py 2002/01/17 00:44:26 1.45
***************
*** 458,463 ****
def abspath(path):
"""Return the absolute version of a path"""
! if path: # Empty path must return current working directory.
from nt import _getfullpathname
try:
path = _getfullpathname(path)
--- 458,473 ----
def abspath(path):
"""Return the absolute version of a path"""
! try:
from nt import _getfullpathname
+ except ImportError: # Not running on Windows - mock up something sensible.
+ global abspath
+ def _abspath(path):
+ if not isabs(path):
+ path = join(os.getcwd(), path)
+ return normpath(path)
+ abspath = _abspath
+ return _abspath(path)
+
+ if path: # Empty path must return current working directory.
try:
path = _getfullpathname(path)