Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(25141)

Delta Between Two Patch Sets: Doc/library/os.rst

Issue 25994: File descriptor leaks in os.scandir()
Left Patch Set: Created 3 years, 7 months ago
Right Patch Set: Created 3 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Doc/whatsnew/3.6.rst » ('j') | Doc/whatsnew/3.6.rst » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 :mod:`os` --- Miscellaneous operating system interfaces 1 :mod:`os` --- Miscellaneous operating system interfaces
2 ======================================================= 2 =======================================================
3 3
4 .. module:: os 4 .. module:: os
5 :synopsis: Miscellaneous operating system interfaces. 5 :synopsis: Miscellaneous operating system interfaces.
6 6
7 7
8 This module provides a portable way of using operating system dependent 8 This module provides a portable way of using operating system dependent
9 functionality. If you just want to read or write a file see :func:`open`, if 9 functionality. If you just want to read or write a file see :func:`open`, if
10 you want to manipulate paths, see the :mod:`os.path` module, and if you want to 10 you want to manipulate paths, see the :mod:`os.path` module, and if you want to
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 the same type as *path*. 1892 the same type as *path*.
1893 1893
1894 The :func:`scandir` iterator supports the :term:`context manager` protocol 1894 The :func:`scandir` iterator supports the :term:`context manager` protocol
1895 and has the following method: 1895 and has the following method:
1896 1896
1897 .. method:: scandir.close() 1897 .. method:: scandir.close()
1898 1898
1899 Close the iterator and free acquired resources. 1899 Close the iterator and free acquired resources.
1900 1900
1901 This is called automatically when the iterator is exhausted or garbage 1901 This is called automatically when the iterator is exhausted or garbage
1902 collected, or when an error happened during iterating. However it 1902 collected, or when an error happened during iterating. However it
Jim.J.Jewett 2016/02/10 23:20:41 happened -> happens
storchaka 2016/02/11 12:20:36 Done.
1903 is advisable to call it explicitly or use the :keyword:`with` 1903 is advisable to call it explicitly or use the :keyword:`with`
1904 statement. 1904 statement.
1905 1905
1906 .. versionadded:: 3.6 1906 .. versionadded:: 3.6
1907 1907
1908 The following example shows a simple use of :func:`scandir` to display all 1908 The following example shows a simple use of :func:`scandir` to display all
1909 the files (excluding directories) in the given *path* that don't start with 1909 the files (excluding directories) in the given *path* that don't start with
1910 ``'.'``. The ``entry.is_file()`` call will generally not make an additional 1910 ``'.'``. The ``entry.is_file()`` call will generally not make an additional
1911 system call:: 1911 system call::
1912 1912
(...skipping 11 matching lines...) Expand all
1924 functions. On Windows, it uses the Win32 1924 functions. On Windows, it uses the Win32
1925 `FindFirstFileW <http://msdn.microsoft.com/en-us/library/windows/desktop/a a364418(v=vs.85).aspx>`_ 1925 `FindFirstFileW <http://msdn.microsoft.com/en-us/library/windows/desktop/a a364418(v=vs.85).aspx>`_
1926 and 1926 and
1927 `FindNextFileW <http://msdn.microsoft.com/en-us/library/windows/desktop/aa 364428(v=vs.85).aspx>`_ 1927 `FindNextFileW <http://msdn.microsoft.com/en-us/library/windows/desktop/aa 364428(v=vs.85).aspx>`_
1928 functions. 1928 functions.
1929 1929
1930 .. versionadded:: 3.5 1930 .. versionadded:: 3.5
1931 1931
1932 .. versionadded:: 3.6 1932 .. versionadded:: 3.6
1933 Added support for the :term:`context manager` protocol and the 1933 Added support for the :term:`context manager` protocol and the
1934 :func:`~scandir.close()` method. If a :func:`scandir` iterator is not 1934 :func:`~scandir.close()` method. If a :func:`scandir` iterator is not
Jim.J.Jewett 2016/02/10 23:20:41 "is not ... nor" -> "is neither ... nor"
Martin Panter 2016/02/11 02:22:20 Yes, even better. (This started off as “is not . .
storchaka 2016/02/11 12:20:36 Done.
1935 exhausted or explicitly closed a :exc:`ResourceWarning` will be emitted 1935 exhausted nor explicitly closed a :exc:`ResourceWarning` will be emitted
1936 in its destructor. 1936 in its destructor.
1937 1937
1938 1938
1939 .. class:: DirEntry 1939 .. class:: DirEntry
1940 1940
1941 Object yielded by :func:`scandir` to expose the file path and other file 1941 Object yielded by :func:`scandir` to expose the file path and other file
1942 attributes of a directory entry. 1942 attributes of a directory entry.
1943 1943
1944 :func:`scandir` will provide as much of this information as possible without 1944 :func:`scandir` will provide as much of this information as possible without
1945 making additional system calls. When a ``stat()`` or ``lstat()`` system call 1945 making additional system calls. When a ``stat()`` or ``lstat()`` system call
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after
3765 :exc:`NotImplementedError` will be raised. 3765 :exc:`NotImplementedError` will be raised.
3766 3766
3767 For an easy-to-use interface to the random number generator 3767 For an easy-to-use interface to the random number generator
3768 provided by your platform, please see :class:`random.SystemRandom`. 3768 provided by your platform, please see :class:`random.SystemRandom`.
3769 3769
3770 .. versionchanged:: 3.5 3770 .. versionchanged:: 3.5
3771 On Linux 3.17 and newer, the ``getrandom()`` syscall is now used 3771 On Linux 3.17 and newer, the ``getrandom()`` syscall is now used
3772 when available. On OpenBSD 5.6 and newer, the C ``getentropy()`` 3772 when available. On OpenBSD 5.6 and newer, the C ``getentropy()``
3773 function is now used. These functions avoid the usage of an internal file 3773 function is now used. These functions avoid the usage of an internal file
3774 descriptor. 3774 descriptor.
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+