Skip to content

Commit d53cf30

Browse files
committed
Tweak proposed shutil documentation
1 parent e8c824f commit d53cf30

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

Doc/library/shutil.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -886,11 +886,11 @@ High-level :term:`context managers <context manager>` for changing a process's e
886886

887887
.. warning::
888888

889-
These may change process-wide states, such as the current working directory,
890-
and as such are not suitable for use in most threaded or async contexts.
891-
They are also not suitable for most non-linear code execution, like generators,
892-
where the program execution is temporarily relinquished. Unless explicitly
893-
desired, you should not yield within these context managers.
889+
These may change process-wide states, and as such are not suitable for use
890+
in most threaded or async contexts. They are also not suitable for most
891+
non-linear code execution, like generators, where the program execution is
892+
temporarily relinquished. Unless explicitly desired, you should not yield
893+
within these context managers.
894894

895895
.. class:: umask(mask)
896896

@@ -899,23 +899,24 @@ High-level :term:`context managers <context manager>` for changing a process's e
899899

900900
This context manager is :ref:`reentrant <reentrant-cms>`.
901901

902-
.. versionadded:: 3.14
902+
.. versionadded:: next
903903

904904
In this example, we use a :class:`umask` context manager, within which we
905-
create a file that only the user can access::
905+
create a file that only the user can access:
906906

907-
>>> from shutil import umask
908-
>>> private_umask = umask(0o077)
909-
>>> with private_umask:
910-
... with open("my-secret-file", "w") as f:
911-
... f.write("I ate all the cake!\n")
907+
.. code-block:: pycon
908+
909+
>>> from shutil import umask
910+
>>> with umask(0o077):
911+
... with open("my-secret-file", "w") as f:
912+
... f.write("I ate all the cake!\n")
912913
913914
The file's permissions are empty for anyone but the user:
914915

915916
.. code-block:: shell-session
916917
917918
$ ls -l my-secret-file
918-
-rw------- 1 jb2170 jb2170 20 Jan 2 01:23 my-secret-file
919+
-rw------- 1 guest guest 20 Jan 1 23:45 my-secret-file
919920
920921
Using :class:`umask` like this is better practice than first creating the file,
921922
and later changing its permissions with :func:`~os.chmod`, between which a

0 commit comments

Comments
 (0)