cpython: 76b2ddaee6bd (original) (raw)

Mercurial > cpython

changeset 101723:76b2ddaee6bd

issue27186: fix fsencode/fsdecode and update tests; patch by Jelle Zijlstra [#27186]

Ethan Furman ethan@stoneleaf.us
date Sat, 04 Jun 2016 13:47:39 -0700
parents 6e6afc4aee57
children 254125a265d2
files Lib/os.py Lib/test/test_os.py
diffstat 2 files changed, 16 insertions(+), 9 deletions(-)[+] [-] Lib/os.py 4 Lib/test/test_os.py 21

line wrap: on

line diff

--- a/Lib/os.py +++ b/Lib/os.py @@ -889,7 +889,7 @@ def _fscodec(): return filename.encode(encoding, errors) else: raise TypeError("expected str, bytes or os.PathLike object, not "

def fsdecode(filename): """ @@ -905,7 +905,7 @@ def _fscodec(): return filename.decode(encoding, errors) else: raise TypeError("expected str, bytes or os.PathLike object, not "

return fsencode, fsdecode

--- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -3107,29 +3107,36 @@ class TestPEP519(unittest.TestCase): self.assertEqual(s, os.fspath(s)) def test_fsencode_fsdecode_return_pathlike(self):

- def fspath(self): return self.path for p in "path/like/object", b"path/like/object":

self.assertEqual(p, os.fspath(pathlike)) self.assertEqual(b"path/like/object", os.fsencode(pathlike)) self.assertEqual("path/like/object", os.fsdecode(pathlike)) def test_fspathlike(self):

-

+

+ def test_garbage_in_exception_out(self): vapor = type('blah', (), {}) for o in int, type, os, vapor():