mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.11] gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls (GH-108248)
gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls (GH-108248)
---------
(cherry picked from commit de33b5c662)
Co-authored-by: Steve Dower <steve.dower@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
d22ac0c605
commit
8927cf0200
3 changed files with 22 additions and 0 deletions
|
|
@ -332,6 +332,10 @@ def test_realpath_basic(self):
|
|||
raise OSError("No free drive letters available")
|
||||
self.assertEqual(ntpath.realpath(d), d)
|
||||
|
||||
# gh-106242: Embedded nulls and non-strict fallback to abspath
|
||||
self.assertEqual(ABSTFN + "\0spam",
|
||||
ntpath.realpath(os_helper.TESTFN + "\0spam", strict=False))
|
||||
|
||||
@os_helper.skip_unless_symlink
|
||||
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
|
||||
def test_realpath_strict(self):
|
||||
|
|
@ -342,6 +346,8 @@ def test_realpath_strict(self):
|
|||
self.addCleanup(os_helper.unlink, ABSTFN)
|
||||
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN, strict=True)
|
||||
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN + "2", strict=True)
|
||||
# gh-106242: Embedded nulls should raise OSError (not ValueError)
|
||||
self.assertRaises(OSError, ntpath.realpath, ABSTFN + "\0spam", strict=True)
|
||||
|
||||
@os_helper.skip_unless_symlink
|
||||
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue