bpo-37412: os.getcwdb() now uses UTF-8 on Windows (GH-14396)

The os.getcwdb() function now uses the UTF-8 encoding on Windows,
rather than the ANSI code page: see PEP 529 for the rationale. The
function is no longer deprecated on Windows.

os.getcwd() and os.getcwdb() now detect integer overflow on memory
allocations. On Unix, these functions properly report MemoryError on
memory allocation failure.
This commit is contained in:
Victor Stinner 2019-06-26 17:31:12 +02:00 committed by GitHub
parent c6a2320e87
commit 689830ee62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 88 additions and 59 deletions

View file

@ -82,6 +82,17 @@ def create_file(filename, content=b'content'):
fp.write(content)
class MiscTests(unittest.TestCase):
def test_getcwd(self):
cwd = os.getcwd()
self.assertIsInstance(cwd, str)
def test_getcwdb(self):
cwd = os.getcwdb()
self.assertIsInstance(cwd, bytes)
self.assertEqual(os.fsdecode(cwd), os.getcwd())
# Tests creating TESTFN
class FileTests(unittest.TestCase):
def setUp(self):