[Python-checkins] cpython (merge 3.6 -> default): Issue #27998: Documented bytes paths support on Windows.
serhiy.storchaka
python-checkins at python.org
Sun Nov 20 01:25:29 EST 2016
https://hg.python.org/cpython/rev/26195e07fcc5
changeset: 105204:26195e07fcc5
parent: 105202:08ca8d3ec707
parent: 105203:ac63c70635db
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Nov 20 08:25:07 2016 +0200
summary:
Issue #27998: Documented bytes paths support on Windows.
files:
Doc/library/os.rst | 23 +++++++++++------------
Doc/whatsnew/3.6.rst | 2 ++
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -2016,13 +2016,11 @@
always requires a system call on Unix but only requires one for
symbolic links on Windows.
- On Unix, *path* can be of type :class:`str` or :class:`bytes` (either
- directly or indirectly through the :class:`PathLike` interface; use
- :func:`~os.fsencode` and :func:`~os.fsdecode` to encode and decode
- :class:`bytes` paths). On Windows, *path* must be of type :class:`str`.
- On both systems, the type of the :attr:`~os.DirEntry.name` and
- :attr:`~os.DirEntry.path` attributes of each :class:`os.DirEntry` will be of
- the same type as *path*.
+ *path* may be a :term:`path-like object`. If *path* is of type ``bytes``
+ (directly or indirectly through the :class:`PathLike` interface),
+ the type of the :attr:`~os.DirEntry.name` and :attr:`~os.DirEntry.path`
+ attributes of each :class:`os.DirEntry` will be ``bytes``; in all other
+ circumstances, they will be of type ``str``.
The :func:`scandir` iterator supports the :term:`context manager` protocol
and has the following method:
@@ -2100,8 +2098,8 @@
The entry's base filename, relative to the :func:`scandir` *path*
argument.
- The :attr:`name` attribute will be of the same type (``str`` or
- ``bytes``) as the :func:`scandir` *path* argument. Use
+ The :attr:`name` attribute will be ``bytes`` if the :func:`scandir`
+ *path* argument is of type ``bytes`` and ``str`` otherwise. Use
:func:`~os.fsdecode` to decode byte filenames.
.. attribute:: path
@@ -2111,8 +2109,8 @@
argument. The path is only absolute if the :func:`scandir` *path*
argument was absolute.
- The :attr:`path` attribute will be of the same type (``str`` or
- ``bytes``) as the :func:`scandir` *path* argument. Use
+ The :attr:`path` attribute will be ``bytes`` if the :func:`scandir`
+ *path* argument is of type ``bytes`` and ``str`` otherwise. Use
:func:`~os.fsdecode` to decode byte filenames.
.. method:: inode()
@@ -2207,7 +2205,8 @@
.. versionadded:: 3.5
.. versionchanged:: 3.6
- Added support for the :class:`~os.PathLike` interface.
+ Added support for the :class:`~os.PathLike` interface. Added support
+ for :class:`bytes` paths on Windows.
.. function:: stat(path, \*, dir_fd=None, follow_symlinks=True)
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -1196,6 +1196,8 @@
:mod:`os` and :mod:`os.path` modules now support
:term:`path-like objects <path-like object>`.
+:func:`~os.scandir` now supports :class:`bytes` paths on Windows.
+
A new :meth:`~os.scandir.close` method allows explicitly closing a
:func:`~os.scandir` iterator. The :func:`~os.scandir` iterator now
supports the :term:`context manager` protocol. If a :func:`scandir`
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list