Skip to content

Commit f024504

Browse files
committed
Deploying to gh-pages from @ 71ca89d 🚀
1 parent fd6ce40 commit f024504

File tree

616 files changed

+35255
-38114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

616 files changed

+35255
-38114
lines changed

_sources/c-api/hash.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
5151
5252
Hash function definition used by :c:func:`PyHash_GetFuncDef`.
5353

54-
.. c::member:: Py_hash_t (*const hash)(const void *, Py_ssize_t)
54+
.. c:member:: Py_hash_t (*const hash)(const void *, Py_ssize_t)
5555
5656
Hash function.
5757

_sources/c-api/init.rst.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,12 @@ code, or when embedding the Python interpreter:
11841184
interpreter lock is also shared by all threads, regardless of to which
11851185
interpreter they belong.
11861186
1187+
.. versionchanged:: 3.12
1188+
1189+
:pep:`684` introduced the possibility
1190+
of a :ref:`per-interpreter GIL <per-interpreter-gil>`.
1191+
See :c:func:`Py_NewInterpreterFromConfig`.
1192+
11871193
11881194
.. c:type:: PyThreadState
11891195
@@ -1875,6 +1881,8 @@ function. You can create and destroy them using the following functions:
18751881
haven't been explicitly destroyed at that point.
18761882
18771883
1884+
.. _per-interpreter-gil:
1885+
18781886
A Per-Interpreter GIL
18791887
---------------------
18801888
@@ -1886,7 +1894,7 @@ being blocked by other interpreters or blocking any others. Thus a
18861894
single Python process can truly take advantage of multiple CPU cores
18871895
when running Python code. The isolation also encourages a different
18881896
approach to concurrency than that of just using threads.
1889-
(See :pep:`554`.)
1897+
(See :pep:`554` and :pep:`684`.)
18901898
18911899
Using an isolated interpreter requires vigilance in preserving that
18921900
isolation. That especially means not sharing any objects or mutable

_sources/c-api/long.rst.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
4040
4141
Return a new :c:type:`PyLongObject` object from *v*, or ``NULL`` on failure.
4242
43-
The current implementation keeps an array of integer objects for all integers
44-
between ``-5`` and ``256``. When you create an int in that range you actually
45-
just get back a reference to the existing object.
43+
.. impl-detail::
44+
45+
CPython keeps an array of integer objects for all integers
46+
between ``-5`` and ``256``. When you create an int in that range
47+
you actually just get back a reference to the existing object.
4648
4749
4850
.. c:function:: PyObject* PyLong_FromUnsignedLong(unsigned long v)
@@ -372,6 +374,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
372374
Set *\*value* to a signed C :c:expr:`int32_t` or :c:expr:`int64_t`
373375
representation of *obj*.
374376
377+
If *obj* is not an instance of :c:type:`PyLongObject`, first call its
378+
:meth:`~object.__index__` method (if present) to convert it to a
379+
:c:type:`PyLongObject`.
380+
375381
If the *obj* value is out of range, raise an :exc:`OverflowError`.
376382
377383
Set *\*value* and return ``0`` on success.

_sources/deprecations/c-api-pending-removal-in-3.18.rst.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Pending removal in Python 3.18
22
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33

4-
* Deprecated private functions (:gh:`128863`):
4+
* The following private functions are deprecated
5+
and planned for removal in Python 3.18:
56

67
* :c:func:`!_PyBytes_Join`: use :c:func:`PyBytes_Join`.
78
* :c:func:`!_PyDict_GetItemStringWithError`: use :c:func:`PyDict_GetItemStringRef`.
8-
* :c:func:`!_PyDict_Pop()`: :c:func:`PyDict_Pop`.
9+
* :c:func:`!_PyDict_Pop()`: use :c:func:`PyDict_Pop`.
910
* :c:func:`!_PyLong_Sign()`: use :c:func:`PyLong_GetSign`.
1011
* :c:func:`!_PyLong_FromDigits` and :c:func:`!_PyLong_New`:
1112
use :c:func:`PyLongWriter_Create`.
@@ -31,7 +32,7 @@ Pending removal in Python 3.18
3132
:c:func:`PyUnicodeWriter_WriteSubstring(writer, str, start, end) <PyUnicodeWriter_WriteSubstring>`.
3233
* :c:func:`!_PyUnicodeWriter_WriteASCIIString`:
3334
replace ``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` with
34-
:c:func:`PyUnicodeWriter_WriteUTF8(writer, str) <PyUnicodeWriter_WriteUTF8>`.
35+
:c:func:`PyUnicodeWriter_WriteASCII(writer, str) <PyUnicodeWriter_WriteASCII>`.
3536
* :c:func:`!_PyUnicodeWriter_WriteLatin1String`:
3637
replace ``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` with
3738
:c:func:`PyUnicodeWriter_WriteUTF8(writer, str) <PyUnicodeWriter_WriteUTF8>`.
@@ -41,5 +42,6 @@ Pending removal in Python 3.18
4142
* :c:func:`!_Py_fopen_obj`: use :c:func:`Py_fopen`.
4243

4344
The `pythoncapi-compat project
44-
<https://github.com/python/pythoncapi-compat/>`__ can be used to get these
45-
new public functions on Python 3.13 and older.
45+
<https://github.com/python/pythoncapi-compat/>`__ can be used to get
46+
these new public functions on Python 3.13 and older.
47+
(Contributed by Victor Stinner in :gh:`128863`.)

_sources/deprecations/pending-removal-in-3.14.rst.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ Pending removal in Python 3.14
3838
is no current event loop set and it decides to create one.
3939
(Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.)
4040

41-
* :mod:`collections.abc`: Deprecated :class:`!collections.abc.ByteString`.
42-
Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`.
43-
For use in typing, prefer a union, like ``bytes | bytearray``,
44-
or :class:`collections.abc.Buffer`.
45-
(Contributed by Shantanu Jain in :gh:`91896`.)
46-
4741
* :mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils.localtime`.
4842
(Contributed by Alan Williams in :gh:`72346`.)
4943

@@ -96,9 +90,6 @@ Pending removal in Python 3.14
9690
if :ref:`named placeholders <sqlite3-placeholders>` are used and
9791
*parameters* is a sequence instead of a :class:`dict`.
9892

99-
* :mod:`typing`: :class:`!typing.ByteString`, deprecated since Python 3.9,
100-
now causes a :exc:`DeprecationWarning` to be emitted when it is used.
101-
10293
* :mod:`urllib`:
10394
:class:`!urllib.parse.Quoter` is deprecated: it was not intended to be a
10495
public API.

_sources/deprecations/pending-removal-in-3.17.rst.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ Pending removal in Python 3.17
88
but it has been retained for backward compatibility, with removal scheduled for Python
99
3.17. Users should use documented introspection helpers like :func:`typing.get_origin`
1010
and :func:`typing.get_args` instead of relying on private implementation details.
11+
- :class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for removal in
12+
Python 3.17. Prefer :class:`~collections.abc.Sequence` or
13+
:class:`~collections.abc.Buffer`. For use in type annotations, prefer a union, like
14+
``bytes | bytearray``, or :class:`collections.abc.Buffer`.
15+
(Contributed by Shantanu Jain in :gh:`91896`.)
16+
17+
* :mod:`collections.abc`:
18+
19+
- :class:`collections.abc.ByteString` is scheduled for removal in Python 3.17. Prefer
20+
:class:`~collections.abc.Sequence` or :class:`~collections.abc.Buffer`. For use in
21+
type annotations, prefer a union, like ``bytes | bytearray``, or
22+
:class:`collections.abc.Buffer`. (Contributed by Shantanu Jain in :gh:`91896`.)

_sources/extending/extending.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ and initialize it by calling :c:func:`PyErr_NewException` in the module's
214214

215215
SpamError = PyErr_NewException("spam.error", NULL, NULL);
216216

217-
Since :c:data:`!SpamError` is a global variable, it will be overwitten every time
217+
Since :c:data:`!SpamError` is a global variable, it will be overwritten every time
218218
the module is reinitialized, when the :c:data:`Py_mod_exec` function is called.
219219

220220
For now, let's avoid the issue: we will block repeated initialization by raising an

_sources/glossary.rst.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ Glossary
2121
right delimiters (parentheses, square brackets, curly braces or triple
2222
quotes), or after specifying a decorator.
2323

24-
* The :const:`Ellipsis` built-in constant.
24+
.. index:: single: ...; ellipsis literal
25+
26+
* The three dots form of the :ref:`Ellipsis <bltin-ellipsis-object>` object.
2527

2628
abstract base class
2729
Abstract base classes complement :term:`duck-typing` by

_sources/howto/enum.rst.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,9 +990,9 @@ Supported ``_sunder_`` names
990990
from the final class
991991
- :meth:`~Enum._generate_next_value_` -- used to get an appropriate value for
992992
an enum member; may be overridden
993-
- :meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing
993+
- :meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing
994994
member.
995-
- :meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an
995+
- :meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an
996996
existing member. See `MultiValueEnum`_ for an example.
997997

998998
.. note::

_sources/howto/remote_debugging.rst.txt

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,78 @@
33
Remote debugging attachment protocol
44
====================================
55

6+
This protocol enables external tools to attach to a running CPython process and
7+
execute Python code remotely.
8+
9+
Most platforms require elevated privileges to attach to another Python process.
10+
11+
.. _permission-requirements:
12+
13+
Permission requirements
14+
=======================
15+
16+
Attaching to a running Python process for remote debugging requires elevated
17+
privileges on most platforms. The specific requirements and troubleshooting
18+
steps depend on your operating system:
19+
20+
.. rubric:: Linux
21+
22+
The tracer process must have the ``CAP_SYS_PTRACE`` capability or equivalent
23+
privileges. You can only trace processes you own and can signal. Tracing may
24+
fail if the process is already being traced, or if it is running with
25+
set-user-ID or set-group-ID. Security modules like Yama may further restrict
26+
tracing.
27+
28+
To temporarily relax ptrace restrictions (until reboot), run:
29+
30+
``echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope``
31+
32+
.. note::
33+
34+
Disabling ``ptrace_scope`` reduces system hardening and should only be done
35+
in trusted environments.
36+
37+
If running inside a container, use ``--cap-add=SYS_PTRACE`` or
38+
``--privileged``, and run as root if needed.
39+
40+
Try re-running the command with elevated privileges:
41+
42+
``sudo -E !!``
43+
44+
45+
.. rubric:: macOS
46+
47+
To attach to another process, you typically need to run your debugging tool
48+
with elevated privileges. This can be done by using ``sudo`` or running as
49+
root.
50+
51+
Even when attaching to processes you own, macOS may block debugging unless
52+
the debugger is run with root privileges due to system security restrictions.
53+
54+
55+
.. rubric:: Windows
56+
57+
To attach to another process, you usually need to run your debugging tool
58+
with administrative privileges. Start the command prompt or terminal as
59+
Administrator.
60+
61+
Some processes may still be inaccessible even with Administrator rights,
62+
unless you have the ``SeDebugPrivilege`` privilege enabled.
63+
64+
To resolve file or folder access issues, adjust the security permissions:
65+
66+
1. Right-click the file or folder and select **Properties**.
67+
2. Go to the **Security** tab to view users and groups with access.
68+
3. Click **Edit** to modify permissions.
69+
4. Select your user account.
70+
5. In **Permissions**, check **Read** or **Full control** as needed.
71+
6. Click **Apply**, then **OK** to confirm.
72+
73+
74+
.. note::
75+
76+
Ensure you've satisfied all :ref:`permission-requirements` before proceeding.
77+
678
This section describes the low-level protocol that enables external tools to
779
inject and execute a Python script within a running CPython process.
880

@@ -374,13 +446,13 @@ To locate a thread:
374446
reliable thread to target.
375447

376448
3. Optionally, use the offset ``interpreter_state.threads_head`` to iterate
377-
through the linked list of all thread states. Each ``PyThreadState`` structure
378-
contains a ``native_thread_id`` field, which may be compared to a target thread
379-
ID to find a specific thread.
449+
through the linked list of all thread states. Each ``PyThreadState``
450+
structure contains a ``native_thread_id`` field, which may be compared to
451+
a target thread ID to find a specific thread.
380452

381-
1. Once a valid ``PyThreadState`` has been found, its address can be used in
382-
later steps of the protocol, such as writing debugger control fields and
383-
scheduling execution.
453+
4. Once a valid ``PyThreadState`` has been found, its address can be used in
454+
later steps of the protocol, such as writing debugger control fields and
455+
scheduling execution.
384456

385457
The following is an example implementation that locates the main thread state::
386458

@@ -454,15 +526,15 @@ its fields are defined by the ``_Py_DebugOffsets`` structure and include the
454526
following:
455527

456528
- ``debugger_script_path``: A fixed-size buffer that holds the full path to a
457-
Python source file (``.py``). This file must be accessible and readable by
458-
the target process when execution is triggered.
529+
Python source file (``.py``). This file must be accessible and readable by
530+
the target process when execution is triggered.
459531

460532
- ``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the
461-
interpreter that a script is ready to be executed.
533+
interpreter that a script is ready to be executed.
462534

463535
- ``eval_breaker``: A field checked by the interpreter during execution.
464-
Setting bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``, value ``1U << 5``) in this
465-
field causes the interpreter to pause and check for debugger activity.
536+
Setting bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``, value ``1U << 5``) in this
537+
field causes the interpreter to pause and check for debugger activity.
466538

467539
To complete the injection, the debugger must perform the following steps:
468540

0 commit comments

Comments
 (0)