diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-02-12 18:14:08 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2018-02-12 18:14:08 (GMT) |
commit | a1d33f742515dc70ae99bc3ea1c851729522afc3 (patch) | |
tree | 3190793be10eb96fd47ea0c44e22c8e8d3e545d5 /Lib | |
parent | 6708be744d032aeffab3e2cf0b064a41a719d8a1 (diff) | |
download | cpython-a1d33f742515dc70ae99bc3ea1c851729522afc3.zip cpython-a1d33f742515dc70ae99bc3ea1c851729522afc3.tar.gz cpython-a1d33f742515dc70ae99bc3ea1c851729522afc3.tar.bz2 |
bpo-29248: Fix os.readlink() on Windows (GH-5577)
The PrintNameOffset field of the reparse data buffer
was treated as a number of characters instead of bytes.
(cherry picked from commit 3c34aad4e7a95913ec7db8e5e948a8fc69047bf7)
Co-authored-by: SSE4 <tomskside@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_os.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index b65ccb7..033e544 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -2171,6 +2171,21 @@ class Win32SymlinkTests(unittest.TestCase): finally: os.chdir(orig_dir) + @unittest.skipUnless(os.path.lexists(r'C:\Users\All Users') + and os.path.exists(r'C:\ProgramData'), + 'Test directories not found') + def test_29248(self): + # os.symlink() calls CreateSymbolicLink, which creates + # the reparse data buffer with the print name stored + # first, so the offset is always 0. CreateSymbolicLink + # stores the "PrintName" DOS path (e.g. "C:\") first, + # with an offset of 0, followed by the "SubstituteName" + # NT path (e.g. "\??\C:\"). The "All Users" link, on + # the other hand, seems to have been created manually + # with an inverted order. + target = os.readlink(r'C:\Users\All Users') + self.assertTrue(os.path.samefile(target, r'C:\ProgramData')) + @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") class Win32JunctionTests(unittest.TestCase): |