Skip to content

Commit 28d8d22

Browse files
committed
Fix merge error in backport.
1 parent 630ffa3 commit 28d8d22

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
@@ -421,9 +421,16 @@ def test_realpath_strict(self):
421421
self.addCleanup(os_helper.unlink, ABSTFN)
422422
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN, strict=True)
423423
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN + "2", strict=True)
424-
# gh-106242: Embedded nulls should raise OSError (not ValueError)
425-
self.assertRaises(OSError, ntpath.realpath, ABSTFN + "\0spam", strict=True)
426424

425+
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
426+
def test_realpath_invalid_paths(self):
427+
realpath = ntpath.realpath
428+
ABSTFN = ntpath.abspath(os_helper.TESTFN)
429+
ABSTFNb = os.fsencode(ABSTFN)
430+
path = ABSTFN + '\x00'
431+
# gh-106242: Embedded nulls and non-strict fallback to abspath
432+
self.assertEqual(realpath(path, strict=False), path)
433+
# gh-106242: Embedded nulls should raise OSError (not ValueError)
427434
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
428435
self.assertRaises(OSError, ntpath.realpath, path, strict=ALLOW_MISSING)
429436
path = ABSTFNb + b'\x00'

0 commit comments

Comments
 (0)