Skip to content

Commit bd8c64e

Browse files
committed
Remove backported tests that won't pass in 3.10 and earlier for reasons
unrelated to the security fix.
1 parent 62cfa92 commit bd8c64e

File tree

1 file changed

+0
-104
lines changed

1 file changed

+0
-104
lines changed

Lib/test/test_ntpath.py

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -348,65 +348,6 @@ def test_realpath_strict(self):
348348
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN, strict=True)
349349
self.assertRaises(FileNotFoundError, ntpath.realpath, ABSTFN + "2", strict=True)
350350

351-
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
352-
def test_realpath_invalid_paths(self):
353-
realpath = ntpath.realpath
354-
ABSTFN = ntpath.abspath(support.TESTFN)
355-
ABSTFNb = os.fsencode(ABSTFN)
356-
path = ABSTFN + '\x00'
357-
# gh-106242: Embedded nulls and non-strict fallback to abspath
358-
self.assertEqual(realpath(path, strict=False), path)
359-
# gh-106242: Embedded nulls should raise OSError (not ValueError)
360-
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
361-
self.assertRaises(OSError, ntpath.realpath, path, strict=ALLOW_MISSING)
362-
path = ABSTFNb + b'\x00'
363-
self.assertEqual(realpath(path, strict=False), path)
364-
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
365-
self.assertRaises(OSError, ntpath.realpath, path, strict=ALLOW_MISSING)
366-
path = ABSTFN + '\\nonexistent\\x\x00'
367-
self.assertEqual(realpath(path, strict=False), path)
368-
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
369-
self.assertRaises(OSError, ntpath.realpath, path, strict=ALLOW_MISSING)
370-
path = ABSTFNb + b'\\nonexistent\\x\x00'
371-
self.assertEqual(realpath(path, strict=False), path)
372-
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
373-
self.assertRaises(OSError, ntpath.realpath, path, strict=ALLOW_MISSING)
374-
path = ABSTFN + '\x00\\..'
375-
self.assertEqual(realpath(path, strict=False), os.getcwd())
376-
self.assertEqual(realpath(path, strict=True), os.getcwd())
377-
self.assertEqual(realpath(path, strict=ALLOW_MISSING), os.getcwd())
378-
path = ABSTFNb + b'\x00\\..'
379-
self.assertEqual(realpath(path, strict=False), os.getcwdb())
380-
self.assertEqual(realpath(path, strict=True), os.getcwdb())
381-
self.assertEqual(realpath(path, strict=ALLOW_MISSING), os.getcwdb())
382-
path = ABSTFN + '\\nonexistent\\x\x00\\..'
383-
self.assertEqual(realpath(path, strict=False), ABSTFN + '\\nonexistent')
384-
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
385-
self.assertEqual(realpath(path, strict=ALLOW_MISSING), ABSTFN + '\\nonexistent')
386-
path = ABSTFNb + b'\\nonexistent\\x\x00\\..'
387-
self.assertEqual(realpath(path, strict=False), ABSTFNb + b'\\nonexistent')
388-
self.assertRaises(OSError, ntpath.realpath, path, strict=True)
389-
self.assertEqual(realpath(path, strict=ALLOW_MISSING), ABSTFNb + b'\\nonexistent')
390-
391-
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
392-
@_parameterize({}, {'strict': True}, {'strict': ALLOW_MISSING})
393-
def test_realpath_invalid_unicode_paths(self, kwargs):
394-
realpath = ntpath.realpath
395-
ABSTFN = ntpath.abspath(support.TESTFN)
396-
ABSTFNb = os.fsencode(ABSTFN)
397-
path = ABSTFNb + b'\xff'
398-
self.assertRaises(UnicodeDecodeError, ntpath.realpath, path, **kwargs)
399-
self.assertRaises(UnicodeDecodeError, ntpath.realpath, path, **kwargs)
400-
path = ABSTFNb + b'\\nonexistent\\\xff'
401-
self.assertRaises(UnicodeDecodeError, ntpath.realpath, path, **kwargs)
402-
self.assertRaises(UnicodeDecodeError, ntpath.realpath, path, **kwargs)
403-
path = ABSTFNb + b'\xff\\..'
404-
self.assertRaises(UnicodeDecodeError, ntpath.realpath, path, **kwargs)
405-
self.assertRaises(UnicodeDecodeError, ntpath.realpath, path, **kwargs)
406-
path = ABSTFNb + b'\\nonexistent\\\xff\\..'
407-
self.assertRaises(UnicodeDecodeError, ntpath.realpath, path, **kwargs)
408-
self.assertRaises(UnicodeDecodeError, ntpath.realpath, path, **kwargs)
409-
410351
@support.skip_unless_symlink
411352
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
412353
@_parameterize({}, {'strict': True}, {'strict': ALLOW_MISSING})
@@ -700,51 +641,6 @@ def test_realpath_cwd(self):
700641
test_file_long,
701642
ntpath.realpath("file.txt", **kwargs))
702643

703-
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
704-
def test_realpath_permission(self):
705-
# Test whether python can resolve the real filename of a
706-
# shortened file name even if it does not have permission to access it.
707-
ABSTFN = ntpath.realpath(support.TESTFN)
708-
709-
support.unlink(ABSTFN)
710-
support.rmtree(ABSTFN)
711-
os.mkdir(ABSTFN)
712-
self.addCleanup(support.rmtree, ABSTFN)
713-
714-
test_file = ntpath.join(ABSTFN, "LongFileName123.txt")
715-
test_file_short = ntpath.join(ABSTFN, "LONGFI~1.TXT")
716-
717-
with open(test_file, "wb") as f:
718-
f.write(b"content")
719-
# Automatic generation of short names may be disabled on
720-
# NTFS volumes for the sake of performance.
721-
# They're not supported at all on ReFS and exFAT.
722-
p = subprocess.run(
723-
# Try to set the short name manually.
724-
['fsutil.exe', 'file', 'setShortName', test_file, 'LONGFI~1.TXT'],
725-
creationflags=subprocess.DETACHED_PROCESS
726-
)
727-
728-
if p.returncode:
729-
raise unittest.SkipTest('failed to set short name')
730-
731-
try:
732-
self.assertPathEqual(test_file, ntpath.realpath(test_file_short))
733-
except AssertionError:
734-
raise unittest.SkipTest('the filesystem seems to lack support for short filenames')
735-
736-
# Deny the right to [S]YNCHRONIZE on the file to
737-
# force nt._getfinalpathname to fail with ERROR_ACCESS_DENIED.
738-
p = subprocess.run(
739-
['icacls.exe', test_file, '/deny', '*S-1-5-32-545:(S)'],
740-
creationflags=subprocess.DETACHED_PROCESS
741-
)
742-
743-
if p.returncode:
744-
raise unittest.SkipTest('failed to deny access to the test file')
745-
746-
self.assertPathEqual(test_file, ntpath.realpath(test_file_short))
747-
748644
def test_expandvars(self):
749645
with support.EnvironmentVarGuard() as env:
750646
env.clear()

0 commit comments

Comments
 (0)