[pypy-commit] pypy default: Fix for issue1520.

arigo noreply at buildbot.pypy.org
Sat Jun 22 17:55:33 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r64955:30e24bcbd0e5
Date: 2013-06-22 17:54 +0200
http://bitbucket.org/pypy/pypy/changeset/30e24bcbd0e5/

Log:	Fix for issue1520.

diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -45,10 +45,7 @@
     raise NotImplementedError
 
 def resolvedirof(filename):
-    try:
-        filename = rpath.rabspath(filename)
-    except OSError:
-        pass
+    filename = rpath.rabspath(filename)
     dirname = rpath.rabspath(os.path.join(filename, '..'))
     if os.path.islink(filename):
         try:
diff --git a/rpython/rlib/rpath.py b/rpython/rlib/rpath.py
--- a/rpython/rlib/rpath.py
+++ b/rpython/rlib/rpath.py
@@ -7,7 +7,12 @@
 
 if os.name == 'posix':
     # the posix version is already RPython, just use it
-    rabspath = os.path.abspath
+    # (but catch exceptions)
+    def rabspath(path):
+        try:
+            return os.path.abspath(path)
+        except OSError:
+            return path
 elif os.name == 'nt':
     def rabspath(path):
         if path == '':
diff --git a/rpython/rlib/test/test_rpath.py b/rpython/rlib/test/test_rpath.py
--- a/rpython/rlib/test/test_rpath.py
+++ b/rpython/rlib/test/test_rpath.py
@@ -12,6 +12,19 @@
 def test_rabspath_absolute_posix():
     assert rpath.rabspath('/foo') == '/foo'
 
+ at py.test.mark.skipif("IS_WINDOWS")
+def test_missing_current_dir(tmpdir):
+    tmpdir1 = str(tmpdir) + '/temporary_removed'
+    curdir1 = os.getcwd()
+    try:
+        os.mkdir(tmpdir1)
+        os.chdir(tmpdir1)
+        os.rmdir(tmpdir1)
+        result = rpath.rabspath('.')
+    finally:
+        os.chdir(curdir1)
+    assert result == '.'
+
 @py.test.mark.skipif("not IS_WINDOWS")
 def test_rabspath_absolute_nt():
     curdrive, _ = os.path.splitdrive(os.getcwd())


More information about the pypy-commit mailing list