]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-105912: document gotcha with using os.fork on macOS (GH-112871) (#113133)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 16 Dec 2023 09:12:10 +0000 (10:12 +0100)
committerGitHub <noreply@github.com>
Sat, 16 Dec 2023 09:12:10 +0000 (10:12 +0100)
gh-105912: document gotcha with using os.fork on macOS (GH-112871)

* gh-105912: document gotcha with using os.fork on macOS

Using ``fork(2)`` on macOS when also using higher-level
system APIs in the parent proces can crash on macOS because
those system APIs are not written to handle this usage
pattern.

There's nothing we can do about this other than documenting
the problem.

(cherry picked from commit 22511f77c2818a138a252e6ddae89725d082f8b0)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Doc/library/os.rst
Doc/library/pty.rst
Doc/library/urllib.request.rst

index 4507fbc8164dc86c16d1b8110b13302aa3246975..8d92ac3957c8a50851b4fb886ccd68a389664141 100644 (file)
@@ -4165,6 +4165,11 @@ written in Python, such as a mail server's external command delivery program.
       If you use TLS sockets in an application calling ``fork()``, see
       the warning in the :mod:`ssl` documentation.
 
+   .. warning::
+
+      On macOS the use of this function is unsafe when mixed with using
+      higher-level system APIs, and that includes using :mod:`urllib.request`.
+
    .. versionchanged:: 3.8
       Calling ``fork()`` in a subinterpreter is no longer supported
       (:exc:`RuntimeError` is raised).
@@ -4204,6 +4209,11 @@ written in Python, such as a mail server's external command delivery program.
 
    .. audit-event:: os.forkpty "" os.forkpty
 
+   .. warning::
+
+      On macOS the use of this function is unsafe when mixed with using
+      higher-level system APIs, and that includes using :mod:`urllib.request`.
+
    .. versionchanged:: 3.12
       If Python is able to detect that your process has multiple
       threads, this now raises a :exc:`DeprecationWarning`. See the
index af9378464edb9f69166926f57a7febd405672bcf..bd2f5ed45cb8b48e1360f8c3a9685277de74d527 100644 (file)
@@ -33,6 +33,9 @@ The :mod:`pty` module defines the following functions:
    file descriptor connected to the child's controlling terminal (and also to the
    child's standard input and output).
 
+   .. warning:: On macOS the use of this function is unsafe when mixed with using
+      higher-level system APIs, and that includes using :mod:`urllib.request`.
+
 
 .. function:: openpty()
 
index 690f01c93a1ee7376aab4617812c15fc7f9f72c6..f55b6813d1e5bc1aa5a9290396bd15609efac02d 100644 (file)
@@ -21,6 +21,14 @@ authentication, redirections, cookies and more.
     The `Requests package <https://requests.readthedocs.io/en/master/>`_
     is recommended for a higher-level HTTP client interface.
 
+.. warning::
+
+   On macOS it is unsafe to use this module in programs using
+   :func:`os.fork` because the :func:`getproxies` implementation for
+   macOS uses a higher-level system API. Set the environment variable
+   ``no_proxy`` to ``*`` to avoid this problem
+   (e.g. ``os.environ["no_proxy"] = "*"``).
+
 .. include:: ../includes/wasm-notavail.rst
 
 The :mod:`urllib.request` module defines the following functions: