Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r93521:50aa133f3ee9
Date: 2017-12-20 17:36 +0100
http://bitbucket.org/pypy/pypy/changeset/50aa133f3ee9/
Log: Test and fix (for lib-python/3/pathlib): 'os.symlink' must exist,
even if it can raise NotImplementedError on Windows
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -80,6 +80,7 @@
'urandom': 'interp_posix.urandom',
'device_encoding': 'interp_posix.device_encoding',
'get_terminal_size': 'interp_posix.get_terminal_size',
+ 'symlink': 'interp_posix.symlink',
'scandir': 'interp_scandir.scandir',
'get_inheritable': 'interp_posix.get_inheritable',
@@ -111,8 +112,6 @@
interpleveldefs['killpg'] = 'interp_posix.killpg'
if hasattr(os, 'getpid'):
interpleveldefs['getpid'] = 'interp_posix.getpid'
- if hasattr(os, 'symlink'):
- interpleveldefs['symlink'] = 'interp_posix.symlink'
if hasattr(os, 'readlink'):
interpleveldefs['readlink'] = 'interp_posix.readlink'
if hasattr(os, 'fork'):
diff --git a/pypy/module/posix/interp_posix.py
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1273,6 +1273,9 @@
and path should be relative; path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError."""
+ if _WIN32:
+ raise oefmt(space.w_NotImplementedError,
+ "symlink() is not implemented for PyPy on Windows")
try:
if rposix.HAVE_SYMLINKAT and dir_fd != DEFAULT_DIR_FD:
src = space.fsencode_w(w_src)
diff --git a/pypy/module/posix/test/test_posix2.py
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -1157,7 +1157,7 @@
expected = min(myprio + 3, 19)
assert os.WEXITSTATUS(status1) == expected
- if hasattr(os, 'symlink'):
+ if sys.platform != 'win32':
def test_symlink(self):
posix = self.posix
bytes_dir = self.bytes_dir
@@ -1187,6 +1187,10 @@
finally:
posix.close(f)
posix.unlink(bytes_dir + '/somelink'.encode())
+ else:
+ def test_symlink(self):
+ posix = self.posix
+ raises(NotImplementedError, posix.symlink, 'a', 'b')
if hasattr(os, 'ftruncate'):
def test_truncate(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit