[3.12] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107981)

* gh-106242: Fix path truncation in os.path.normpath (GH-106816)
* gh-106242: Minor fixup to avoid compiler warnings

---------

Co-authored-by: Finn Womack <flan313@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Steve Dower 2023-08-17 00:19:48 +01:00 committed by GitHub
parent 2a00cf2db8
commit ede9895881
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 10 deletions

View file

@ -460,6 +460,10 @@ class CommonTest(GenericTest):
for path in ('', '.', '/', '\\', '///foo/.//bar//'):
self.assertIsInstance(self.pathmodule.normpath(path), str)
def test_normpath_issue106242(self):
for path in ('\x00', 'foo\x00bar', '\x00\x00', '\x00foo', 'foo\x00'):
self.assertEqual(self.pathmodule.normpath(path), path)
def test_abspath_issue3426(self):
# Check that abspath returns unicode when the arg is unicode
# with both ASCII and non-ASCII cwds.