mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-9949: Enable symlink traversal for ntpath.realpath (GH-15287)
This commit is contained in:
parent
e1c638da6a
commit
75e064962e
8 changed files with 304 additions and 32 deletions
|
@ -723,11 +723,13 @@ class TestDiscovery(unittest.TestCase):
|
|||
original_listdir = os.listdir
|
||||
original_isfile = os.path.isfile
|
||||
original_isdir = os.path.isdir
|
||||
original_realpath = os.path.realpath
|
||||
|
||||
def cleanup():
|
||||
os.listdir = original_listdir
|
||||
os.path.isfile = original_isfile
|
||||
os.path.isdir = original_isdir
|
||||
os.path.realpath = original_realpath
|
||||
del sys.modules['foo']
|
||||
if full_path in sys.path:
|
||||
sys.path.remove(full_path)
|
||||
|
@ -742,6 +744,10 @@ class TestDiscovery(unittest.TestCase):
|
|||
os.listdir = listdir
|
||||
os.path.isfile = isfile
|
||||
os.path.isdir = isdir
|
||||
if os.name == 'nt':
|
||||
# ntpath.realpath may inject path prefixes when failing to
|
||||
# resolve real files, so we substitute abspath() here instead.
|
||||
os.path.realpath = os.path.abspath
|
||||
return full_path
|
||||
|
||||
def test_detect_module_clash(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue