Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r63728:d531b90c42b5
Date: 2013-04-28 12:10 -0700
http://bitbucket.org/pypy/pypy/changeset/d531b90c42b5/

Log:    we can't always pass in arbitrary unicode values when the
        filesystemencoding is ascii or similar

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
@@ -302,8 +302,14 @@
         assert expected in result
 
     def test_undecodable_filename(self):
+        import sys
         posix = self.posix
-        assert posix.access('caf\xe9', posix.R_OK) is False
+        try:
+            'caf\xe9'.encode(sys.getfilesystemencoding(), 'surrogateescape')
+        except UnicodeEncodeError:
+            pass # probably ascii
+        else:
+            assert posix.access('caf\xe9', posix.R_OK) is False
         assert posix.access(b'caf\xe9', posix.R_OK) is False
         assert posix.access('caf\udcc0', posix.R_OK) is False
         assert posix.access(b'caf\xc3', posix.R_OK) is False
@@ -959,8 +965,18 @@
 
     @py.test.mark.dont_track_allocations('putenv intentionally keeps strings 
alive')
     def test_environ_nonascii(self):
+        import sys
+        name, value = 'PYPY_TEST_&#26085;&#26412;', 'foobar&#26085;&#26412;'
+        if not sys.platform == 'win32':
+            fsencoding = sys.getfilesystemencoding()
+            for s in name, value:
+                try:
+                    s.encode(fsencoding, 'surrogateescape')
+                except UnicodeEncodeError:
+                    skip("Requires %s.encode(sys.getfilesystemencoding(), "
+                         "'surogateescape') to succeed (or win32)" % ascii(s))
+
         os = self.os
-        name, value = 'PYPY_TEST_&#26085;&#26412;', 'foobar&#26085;&#26412;'
         os.environ[name] = value
         assert os.environ[name] == value
         assert os.getenv(name) == value
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to