Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 387e6e3

Browse files
committed
Back out pathlib.Path.path attr. (Merge 3.4->3.5)
2 parents d8bf09c + 3d4d01f commit 387e6e3

4 files changed

Lines changed: 0 additions & 62 deletions

File tree

Doc/library/pathlib.rst

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -365,28 +365,6 @@ Pure paths provide the following methods and properties:
365365
''
366366

367367

368-
.. data:: PurePath.path
369-
370-
A string representing the full path::
371-
372-
>>> PurePosixPath('my/library/setup.py').path
373-
'my/library/setup.py'
374-
375-
This always returns the same value as ``str(p)``; it is included to
376-
serve as a one-off protocol. Code that wants to support both
377-
strings and ``pathlib.Path`` objects as filenames can write
378-
``arg = getattr(arg, 'path', arg)`` to get the path as a string.
379-
This can then be passed to various system calls or library
380-
functions that expect a string. Unlike the alternative
381-
``arg = str(arg)``, this will still raise an exception if an object
382-
of some other type is given by accident.
383-
384-
A nice advantage is that this protocol is also supported by
385-
:class:`os.DirEntry` objects returned by :func:`os.scandir`.
386-
387-
.. versionadded:: 3.4.5
388-
.. versionadded:: 3.5.2
389-
390368
.. data:: PurePath.suffix
391369

392370
The file extension of the final component, if any::

Lib/pathlib.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,6 @@ def __str__(self):
693693
self._parts) or '.'
694694
return self._str
695695

696-
@property
697-
def path(self):
698-
try:
699-
return self._str
700-
except AttributeError:
701-
return str(self)
702-
703696
def as_posix(self):
704697
"""Return the string representation of the path with forward (/)
705698
slashes."""

Lib/test/test_pathlib.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -477,22 +477,6 @@ def test_name_common(self):
477477
self.assertEqual(P('a/b.py').name, 'b.py')
478478
self.assertEqual(P('/a/b.py').name, 'b.py')
479479

480-
def test_path_common(self):
481-
P = self.cls
482-
def check(arg, expected=None):
483-
if expected is None:
484-
expected = arg
485-
self.assertEqual(P(arg).path, expected.replace('/', self.sep))
486-
check('', '.')
487-
check('.')
488-
check('/')
489-
check('a/b')
490-
check('/a/b')
491-
check('/a/b/', '/a/b')
492-
check('/a/b/.', '/a/b')
493-
check('a/b.py')
494-
check('/a/b.py')
495-
496480
def test_suffix_common(self):
497481
P = self.cls
498482
self.assertEqual(P('').suffix, '')
@@ -915,17 +899,6 @@ def test_name(self):
915899
self.assertEqual(P('//My.py/Share.php').name, '')
916900
self.assertEqual(P('//My.py/Share.php/a/b').name, 'b')
917901

918-
def test_path(self):
919-
P = self.cls
920-
self.assertEqual(P('c:').path, 'c:')
921-
self.assertEqual(P('c:/').path, 'c:\\')
922-
self.assertEqual(P('c:a/b').path, 'c:a\\b')
923-
self.assertEqual(P('c:/a/b').path, 'c:\\a\\b')
924-
self.assertEqual(P('c:a/b.py').path, 'c:a\\b.py')
925-
self.assertEqual(P('c:/a/b.py').path, 'c:\\a\\b.py')
926-
self.assertEqual(P('//My.py/Share.php').path, '\\\\My.py\\Share.php\\')
927-
self.assertEqual(P('//My.py/Share.php/a/b').path, '\\\\My.py\\Share.php\\a\\b')
928-
929902
def test_suffix(self):
930903
P = self.cls
931904
self.assertEqual(P('c:').suffix, '')

Misc/NEWS

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,6 @@ Library
370370
- Issue #25672: In the ssl module, enable the SSL_MODE_RELEASE_BUFFERS mode
371371
option if it is safe to do so.
372372

373-
- Issue #22570: Add 'path' attribute to pathlib.Path objects,
374-
returning the same as str(), to make it more similar to DirEntry.
375-
Library code can now write getattr(p, 'path', p) to get the path as
376-
a string from a Path, a DirEntry, or a plain string. This is
377-
essentially a small one-off protocol.
378-
379373
- Issue #26012: Don't traverse into symlinks for ** pattern in
380374
pathlib.Path.[r]glob().
381375

0 commit comments

Comments
 (0)