cpython: cbc78ca21977 (original) (raw)
Mercurial > cpython
changeset 102745:cbc78ca21977 3.5
#2466: ismount now recognizes mount points user can't access. Patch by Robin Roth, reviewed by Serhiy Storchaka, comment wording tweaked by me. [#2466]
R David Murray rdmurray@bitdance.com | |
---|---|
date | Thu, 18 Aug 2016 21:27:48 -0400 |
parents | ba45fbb16499 |
children | db9126139969 bad82d4bdf8c |
files | Lib/posixpath.py Lib/test/test_posixpath.py Misc/ACKS Misc/NEWS |
diffstat | 4 files changed, 27 insertions(+), 2 deletions(-)[+] [-] Lib/posixpath.py 1 Lib/test/test_posixpath.py 24 Misc/ACKS 1 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -193,6 +193,7 @@ def ismount(path): parent = join(path, b'..') else: parent = join(path, '..')
--- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -1,7 +1,5 @@ -import itertools import os import posixpath -import sys import unittest import warnings from posixpath import realpath, abspath, dirname, basename @@ -213,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[](#l2.17)
# readable, which used to return False.[](#l2.18)
save_lstat = os.lstat[](#l2.19)
def fake_lstat(path):[](#l2.20)
st_ino = 0[](#l2.21)
st_dev = 0[](#l2.22)
if path.startswith(ABSTFN) and path != ABSTFN:[](#l2.23)
# ismount tries to read something inside the ABSTFN directory;[](#l2.24)
# simulate this being forbidden (no read permission).[](#l2.25)
raise OSError("Fake [Errno 13] Permission denied")[](#l2.26)
if path == ABSTFN:[](#l2.27)
st_dev = 1[](#l2.28)
st_ino = 1[](#l2.29)
return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0))[](#l2.30)
try:[](#l2.31)
os.lstat = fake_lstat[](#l2.32)
self.assertIs(posixpath.ismount(ABSTFN), True)[](#l2.33)
finally:[](#l2.34)
os.lstat = save_lstat[](#l2.35)
+ def test_expanduser(self): self.assertEqual(posixpath.expanduser("foo"), "foo") self.assertEqual(posixpath.expanduser(b"foo"), b"foo")
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -1258,6 +1258,7 @@ Guido van Rossum Just van Rossum Hugo van Rossum Saskia van Rossum +Robin Roth Clement Rouault Donald Wallace Rouse II Liam Routt
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -38,6 +38,9 @@ Core and Builtins Library ------- +- Issue #2466: posixpath.ismount now correctly recognizes mount points which