diff options
author | R David Murray <rdmurray@bitdance.com> | 2016-08-19 01:31:13 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2016-08-19 01:31:13 (GMT) |
commit | c19960385342e95da7437cec908c12ff5cd53bf2 (patch) | |
tree | 1c421c1acf8ea245ba342dfa05d3e4bb57817109 | |
parent | 696738cf1bff86431fa611b78345db1434320ea4 (diff) | |
parent | 750018b91aeb5dfb46dc1e156a8b4e7aefb6d59f (diff) | |
download | cpython-c19960385342e95da7437cec908c12ff5cd53bf2.zip cpython-c19960385342e95da7437cec908c12ff5cd53bf2.tar.gz cpython-c19960385342e95da7437cec908c12ff5cd53bf2.tar.bz2 |
Merge: #2466: ismount now recognizes mount points user can't access.
-rw-r--r-- | Lib/posixpath.py | 1 | ||||
-rw-r--r-- | Lib/test/test_posixpath.py | 22 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
4 files changed, 27 insertions, 0 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 7bb4d59..d9f3f99 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -193,6 +193,7 @@ def ismount(path): parent = join(path, b'..') else: parent = join(path, '..') + parent = realpath(parent) try: s2 = os.lstat(parent) except OSError: diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index 4ff445d..0783c36 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -211,6 +211,28 @@ class PosixPathTest(unittest.TestCase): finally: os.lstat = save_lstat + @unittest.skipIf(posix is None, "Test requires posix module") + def test_ismount_directory_not_readable(self): + # issue #2466: Simulate ismount run on a directory that is not + # readable, which used to return False. + save_lstat = os.lstat + def fake_lstat(path): + st_ino = 0 + st_dev = 0 + if path.startswith(ABSTFN) and path != ABSTFN: + # ismount tries to read something inside the ABSTFN directory; + # simulate this being forbidden (no read permission). + raise OSError("Fake [Errno 13] Permission denied") + if path == ABSTFN: + st_dev = 1 + st_ino = 1 + return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0)) + try: + os.lstat = fake_lstat + self.assertIs(posixpath.ismount(ABSTFN), True) + finally: + os.lstat = save_lstat + def test_expanduser(self): self.assertEqual(posixpath.expanduser("foo"), "foo") self.assertEqual(posixpath.expanduser(b"foo"), b"foo") @@ -1273,6 +1273,7 @@ Guido van Rossum Just van Rossum Hugo van Rossum Saskia van Rossum +Robin Roth Clement Rouault Donald Wallace Rouse II Liam Routt @@ -76,6 +76,9 @@ Core and Builtins Library ------- +- Issue #2466: posixpath.ismount now correctly recognizes mount points which + the user does not have permission to access. + - Issue #25958: Support "anti-registration" of special methods from various ABCs, like __hash__, __iter__ or __len__. All these (and several more) can be set to None in an implementation class and the |