Skip to content

Commit ead96bb

Browse files
committed
Fix merge error in backport.
1 parent 2c2df0d commit ead96bb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Lib/test/test_ntpath.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,16 @@ def test_realpath_strict(self):
483483
self.addCleanup(os_helper.unlink, ABSTFN)
484484
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN, strict=True)
485485
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN + "2", strict=True)
486-
# gh-106242: Embedded nulls should raise OSError (not ValueError)
487-
self.assertRaises(OSError, ntpath.realpath, ABSTFN + "\0spam", strict=True)
488486

487+
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
488+
def test_realpath_invalid_paths(self):
489+
realpath = ntpath.realpath
490+
ABSTFN = ntpath.abspath(os_helper.TESTFN)
491+
ABSTFNb = os.fsencode(ABSTFN)
492+
path = ABSTFN + '\x00'
493+
# gh-106242: Embedded nulls and non-strict fallback to abspath
494+
self.assertEqual(realpath(path, strict=False), path)
495+
# gh-106242: Embedded nulls should raise OSError (not ValueError)
489496
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
490497
self.assertRaises(OSError, ntpath.realpath, path, strict=ALLOW_MISSING)
491498
path = ABSTFNb + b'\x00'

0 commit comments

Comments
 (0)