]> granicus.if.org Git - python/commitdiff
Back out 7e9605697dfc, 2e3c31ab586a, 759b2cecc289.
authorGuido van Rossum <guido@python.org>
Thu, 19 May 2016 20:00:21 +0000 (13:00 -0700)
committerGuido van Rossum <guido@python.org>
Thu, 19 May 2016 20:00:21 +0000 (13:00 -0700)
These added a path attribute to pathlib.Path objects, and docs.
Instead, we're going to use PEP 519.

(Starting in the 3.4 branch and merging forward from there since that's what I did originally.)

Doc/library/pathlib.rst
Lib/pathlib.py
Lib/test/test_pathlib.py
Misc/NEWS

index cb066bdc094e3b6227335a14dde2ddcb4f1f9d10..24e2a308dfe2653eafedd33937fa3941aeca17d5 100644 (file)
@@ -365,24 +365,6 @@ Pure paths provide the following methods and properties:
       ''
 
 
-.. data:: PurePath.path
-
-   A string representing the full path::
-
-      >>> PurePosixPath('my/library/setup.py').path
-      'my/library/setup.py'
-
-   This always returns the same value as ``str(p)``; it is included to
-   serve as a one-off protocol.  Code that wants to support both
-   strings and ``pathlib.Path`` objects as filenames can write
-   ``arg = getattr(arg, 'path', arg)`` to get the path as a string.
-   This can then be passed to various system calls or library
-   functions that expect a string.  Unlike the alternative
-   ``arg = str(arg)``, this will still raise an exception if an object
-   of some other type is given by accident.
-
-   .. versionadded:: 3.4.5
-
 .. data:: PurePath.suffix
 
    The file extension of the final component, if any::
index 8fef2590b85a4c8435408e27aec564261ec55cdb..4fa872d62023f881d921d2b761edd01b71f453b3 100644 (file)
@@ -648,13 +648,6 @@ class PurePath(object):
                                                   self._parts) or '.'
             return self._str
 
-    @property
-    def path(self):
-        try:
-            return self._str
-        except AttributeError:
-            return str(self)
-
     def as_posix(self):
         """Return the string representation of the path with forward (/)
         slashes."""
index 6b3c70de94dba565bfeee5e9cd1c1f3d46f8f420..0d98f24868334142b1388afe0fd956505562e636 100644 (file)
@@ -480,22 +480,6 @@ class _BasePurePathTest(object):
         self.assertEqual(P('a/b.py').name, 'b.py')
         self.assertEqual(P('/a/b.py').name, 'b.py')
 
-    def test_path_common(self):
-        P = self.cls
-        def check(arg, expected=None):
-            if expected is None:
-                expected = arg
-            self.assertEqual(P(arg).path, expected.replace('/', self.sep))
-        check('', '.')
-        check('.')
-        check('/')
-        check('a/b')
-        check('/a/b')
-        check('/a/b/', '/a/b')
-        check('/a/b/.', '/a/b')
-        check('a/b.py')
-        check('/a/b.py')
-
     def test_suffix_common(self):
         P = self.cls
         self.assertEqual(P('').suffix, '')
@@ -919,17 +903,6 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
         self.assertEqual(P('//My.py/Share.php').name, '')
         self.assertEqual(P('//My.py/Share.php/a/b').name, 'b')
 
-    def test_path(self):
-        P = self.cls
-        self.assertEqual(P('c:').path, 'c:')
-        self.assertEqual(P('c:/').path, 'c:\\')
-        self.assertEqual(P('c:a/b').path, 'c:a\\b')
-        self.assertEqual(P('c:/a/b').path, 'c:\\a\\b')
-        self.assertEqual(P('c:a/b.py').path, 'c:a\\b.py')
-        self.assertEqual(P('c:/a/b.py').path, 'c:\\a\\b.py')
-        self.assertEqual(P('//My.py/Share.php').path, '\\\\My.py\\Share.php\\')
-        self.assertEqual(P('//My.py/Share.php/a/b').path, '\\\\My.py\\Share.php\\a\\b')
-
     def test_suffix(self):
         P = self.cls
         self.assertEqual(P('c:').suffix, '')
index 8db17d8d216aefc27e84b91878389d93870aab67..86ef3d762f8d2ea8a672ff50d793d41f8be957aa 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,12 +21,6 @@ Library
 
 - Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates.
 
-- Issue #22570: Add 'path' attribute to pathlib.Path objects,
-  returning the same as str(), to make it more similar to DirEntry.
-  Library code can now write getattr(p, 'path', p) to get the path as
-  a string from a Path, a DirEntry, or a plain string.  This is
-  essentially a small one-off protocol.
-
 - Issue #26012: Don't traverse into symlinks for ** pattern in
   pathlib.Path.[r]glob().