Skip to content

Commit 05d7906

Browse files
committed
Fix merge error in backport.
1 parent 0aaaeaa commit 05d7906

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Lib/test/test_ntpath.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,15 @@ def test_realpath_strict(self):
350350
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN, strict=True)
351351
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN + "2", strict=True)
352352

353+
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
354+
def test_realpath_invalid_paths(self):
355+
realpath = ntpath.realpath
356+
ABSTFN = ntpath.abspath(os_helper.TESTFN)
357+
ABSTFNb = os.fsencode(ABSTFN)
358+
path = ABSTFN + '\x00'
359+
# gh-106242: Embedded nulls and non-strict fallback to abspath
360+
self.assertEqual(realpath(path, strict=False), path)
361+
# gh-106242: Embedded nulls should raise OSError (not ValueError)
353362
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
354363
self.assertRaises(OSError, ntpath.realpath, path, strict=ALLOW_MISSING)
355364
path = ABSTFNb + b'\x00'

0 commit comments

Comments
 (0)