Skip to content

Commit 43f51a4

Browse files
committed
Merge branch 'main' into gh-127381-purepathbase
2 parents be2d2eb + 8d9f52a commit 43f51a4

File tree

367 files changed

+8345
-3534
lines changed

Some content is hidden

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

367 files changed

+8345
-3534
lines changed

.github/workflows/reusable-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run: |
4343
brew install pkg-config [email protected] xz gdbm tcl-tk@8 make
4444
# Because alternate versions are not symlinked into place by default:
45-
brew link tcl-tk@8
45+
brew link --overwrite tcl-tk@8
4646
- name: Configure CPython
4747
run: |
4848
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \

.github/workflows/reusable-windows-msi.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ jobs:
2424
with:
2525
persist-credentials: false
2626
- name: Build CPython installer
27-
run: .\Tools\msi\build.bat --doc -"${ARCH}"
27+
run: ./Tools/msi/build.bat --doc -"${ARCH}"
28+
shell: bash

Doc/c-api/frame.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,34 @@ See also :ref:`Reflection <reflection>`.
132132
.. versionadded:: 3.11
133133
134134
.. versionchanged:: 3.13
135-
As part of :pep:`667`, return a proxy object for optimized scopes.
135+
As part of :pep:`667`, return an instance of :c:var:`PyFrameLocalsProxy_Type`.
136136
137137
138138
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
139139
140140
Return the line number that *frame* is currently executing.
141141
142142
143+
Frame Locals Proxies
144+
^^^^^^^^^^^^^^^^^^^^
145+
146+
.. versionadded:: 3.13
147+
148+
The :attr:`~frame.f_locals` attribute on a :ref:`frame object <frame-objects>`
149+
is an instance of a "frame-locals proxy". The proxy object exposes a
150+
write-through view of the underlying locals dictionary for the frame. This
151+
ensures that the variables exposed by ``f_locals`` are always up to date with
152+
the live local variables in the frame itself.
153+
154+
See :pep:`667` for more information.
155+
156+
.. c:var:: PyTypeObject PyFrameLocalsProxy_Type
157+
158+
The type of frame :func:`locals` proxy objects.
159+
160+
.. c:function:: int PyFrameLocalsProxy_Check(PyObject *obj)
161+
162+
Return non-zero if *obj* is a frame :func:`locals` proxy.
143163
144164
Internal Frames
145165
^^^^^^^^^^^^^^^

Doc/c-api/init.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,15 @@ Initializing and finalizing the interpreter
567567
customized Python that always runs in isolated mode using
568568
:c:func:`Py_RunMain`.
569569
570+
.. c:function:: int PyUnstable_AtExit(PyInterpreterState *interp, void (*func)(void *), void *data)
571+
572+
Register an :mod:`atexit` callback for the target interpreter *interp*.
573+
This is similar to :c:func:`Py_AtExit`, but takes an explicit interpreter and
574+
data pointer for the callback.
575+
576+
The :term:`GIL` must be held for *interp*.
577+
578+
.. versionadded:: 3.13
570579
571580
Process-wide parameters
572581
=======================

Doc/c-api/long.rst

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,3 +653,177 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
653653
654654
.. versionadded:: 3.12
655655
656+
657+
Export API
658+
^^^^^^^^^^
659+
660+
.. versionadded:: 3.14
661+
662+
.. c:struct:: PyLongLayout
663+
664+
Layout of an array of "digits" ("limbs" in the GMP terminology), used to
665+
represent absolute value for arbitrary precision integers.
666+
667+
Use :c:func:`PyLong_GetNativeLayout` to get the native layout of Python
668+
:class:`int` objects, used internally for integers with "big enough"
669+
absolute value.
670+
671+
See also :data:`sys.int_info` which exposes similar information in Python.
672+
673+
.. c:member:: uint8_t bits_per_digit
674+
675+
Bits per digit. For example, a 15 bit digit means that bits 0-14 contain
676+
meaningful information.
677+
678+
.. c:member:: uint8_t digit_size
679+
680+
Digit size in bytes. For example, a 15 bit digit will require at least 2
681+
bytes.
682+
683+
.. c:member:: int8_t digits_order
684+
685+
Digits order:
686+
687+
- ``1`` for most significant digit first
688+
- ``-1`` for least significant digit first
689+
690+
.. c:member:: int8_t digit_endianness
691+
692+
Digit endianness:
693+
694+
- ``1`` for most significant byte first (big endian)
695+
- ``-1`` for least significant byte first (little endian)
696+
697+
698+
.. c:function:: const PyLongLayout* PyLong_GetNativeLayout(void)
699+
700+
Get the native layout of Python :class:`int` objects.
701+
702+
See the :c:struct:`PyLongLayout` structure.
703+
704+
The function must not be called before Python initialization nor after
705+
Python finalization. The returned layout is valid until Python is
706+
finalized. The layout is the same for all Python sub-interpreters
707+
in a process, and so it can be cached.
708+
709+
710+
.. c:struct:: PyLongExport
711+
712+
Export of a Python :class:`int` object.
713+
714+
There are two cases:
715+
716+
* If :c:member:`digits` is ``NULL``, only use the :c:member:`value` member.
717+
* If :c:member:`digits` is not ``NULL``, use :c:member:`negative`,
718+
:c:member:`ndigits` and :c:member:`digits` members.
719+
720+
.. c:member:: int64_t value
721+
722+
The native integer value of the exported :class:`int` object.
723+
Only valid if :c:member:`digits` is ``NULL``.
724+
725+
.. c:member:: uint8_t negative
726+
727+
``1`` if the number is negative, ``0`` otherwise.
728+
Only valid if :c:member:`digits` is not ``NULL``.
729+
730+
.. c:member:: Py_ssize_t ndigits
731+
732+
Number of digits in :c:member:`digits` array.
733+
Only valid if :c:member:`digits` is not ``NULL``.
734+
735+
.. c:member:: const void *digits
736+
737+
Read-only array of unsigned digits. Can be ``NULL``.
738+
739+
740+
.. c:function:: int PyLong_Export(PyObject *obj, PyLongExport *export_long)
741+
742+
Export a Python :class:`int` object.
743+
744+
*export_long* must point to a :c:struct:`PyLongExport` structure allocated
745+
by the caller. It must not be ``NULL``.
746+
747+
On success, fill in *\*export_long* and return ``0``.
748+
On error, set an exception and return ``-1``.
749+
750+
:c:func:`PyLong_FreeExport` must be called when the export is no longer
751+
needed.
752+
753+
.. impl-detail::
754+
This function always succeeds if *obj* is a Python :class:`int` object
755+
or a subclass.
756+
757+
758+
.. c:function:: void PyLong_FreeExport(PyLongExport *export_long)
759+
760+
Release the export *export_long* created by :c:func:`PyLong_Export`.
761+
762+
.. impl-detail::
763+
Calling :c:func:`PyLong_FreeExport` is optional if *export_long->digits*
764+
is ``NULL``.
765+
766+
767+
PyLongWriter API
768+
^^^^^^^^^^^^^^^^
769+
770+
The :c:type:`PyLongWriter` API can be used to import an integer.
771+
772+
.. versionadded:: 3.14
773+
774+
.. c:struct:: PyLongWriter
775+
776+
A Python :class:`int` writer instance.
777+
778+
The instance must be destroyed by :c:func:`PyLongWriter_Finish` or
779+
:c:func:`PyLongWriter_Discard`.
780+
781+
782+
.. c:function:: PyLongWriter* PyLongWriter_Create(int negative, Py_ssize_t ndigits, void **digits)
783+
784+
Create a :c:type:`PyLongWriter`.
785+
786+
On success, allocate *\*digits* and return a writer.
787+
On error, set an exception and return ``NULL``.
788+
789+
*negative* is ``1`` if the number is negative, or ``0`` otherwise.
790+
791+
*ndigits* is the number of digits in the *digits* array. It must be
792+
greater than 0.
793+
794+
*digits* must not be NULL.
795+
796+
After a successful call to this function, the caller should fill in the
797+
array of digits *digits* and then call :c:func:`PyLongWriter_Finish` to get
798+
a Python :class:`int`.
799+
The layout of *digits* is described by :c:func:`PyLong_GetNativeLayout`.
800+
801+
Digits must be in the range [``0``; ``(1 << bits_per_digit) - 1``]
802+
(where the :c:struct:`~PyLongLayout.bits_per_digit` is the number of bits
803+
per digit).
804+
Any unused most significant digits must be set to ``0``.
805+
806+
Alternately, call :c:func:`PyLongWriter_Discard` to destroy the writer
807+
instance without creating an :class:`~int` object.
808+
809+
810+
.. c:function:: PyObject* PyLongWriter_Finish(PyLongWriter *writer)
811+
812+
Finish a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`.
813+
814+
On success, return a Python :class:`int` object.
815+
On error, set an exception and return ``NULL``.
816+
817+
The function takes care of normalizing the digits and converts the object
818+
to a compact integer if needed.
819+
820+
The writer instance and the *digits* array are invalid after the call.
821+
822+
823+
.. c:function:: void PyLongWriter_Discard(PyLongWriter *writer)
824+
825+
Discard a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`.
826+
827+
*writer* must not be ``NULL``.
828+
829+
The writer instance and the *digits* array are invalid after the call.

Doc/c-api/monitoring.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ See :mod:`sys.monitoring` for descriptions of the events.
7575
Fire a ``JUMP`` event.
7676
7777
78-
.. c:function:: int PyMonitoring_FireBranchEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *target_offset)
78+
.. c:function:: int PyMonitoring_FireBranchLeftEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *target_offset)
7979
80-
Fire a ``BRANCH`` event.
80+
Fire a ``BRANCH_LEFT`` event.
81+
82+
83+
.. c:function:: int PyMonitoring_FireBranchRightEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *target_offset)
84+
85+
Fire a ``BRANCH_RIGHT`` event.
8186
8287
8388
.. c:function:: int PyMonitoring_FireCReturnEvent(PyMonitoringState *state, PyObject *codelike, int32_t offset, PyObject *retval)
@@ -168,7 +173,8 @@ would typically correspond to a python function.
168173
================================================== =====================================
169174
Macro Event
170175
================================================== =====================================
171-
.. c:macro:: PY_MONITORING_EVENT_BRANCH :monitoring-event:`BRANCH`
176+
.. c:macro:: PY_MONITORING_EVENT_BRANCH_LEFT :monitoring-event:`BRANCH_LEFT`
177+
.. c:macro:: PY_MONITORING_EVENT_BRANCH_RIGHT :monitoring-event:`BRANCH_RIGHT`
172178
.. c:macro:: PY_MONITORING_EVENT_CALL :monitoring-event:`CALL`
173179
.. c:macro:: PY_MONITORING_EVENT_C_RAISE :monitoring-event:`C_RAISE`
174180
.. c:macro:: PY_MONITORING_EVENT_C_RETURN :monitoring-event:`C_RETURN`

Doc/c-api/object.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ Object Protocol
509509
iterated.
510510
511511
512+
.. c:function:: PyObject* PyObject_SelfIter(PyObject *obj)
513+
514+
This is equivalent to the Python ``__iter__(self): return self`` method.
515+
It is intended for :term:`iterator` types, to be used in the :c:member:`PyTypeObject.tp_iter` slot.
516+
517+
512518
.. c:function:: PyObject* PyObject_GetAIter(PyObject *o)
513519
514520
This is the equivalent to the Python expression ``aiter(o)``. Takes an

Doc/c-api/sequence.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ Sequence Protocol
105105
equivalent to the Python expression ``value in o``.
106106
107107
108+
.. c:function:: int PySequence_In(PyObject *o, PyObject *value)
109+
110+
Alias for :c:func:`PySequence_Contains`.
111+
112+
.. deprecated:: 3.14
113+
The function is :term:`soft deprecated` and should no longer be used to
114+
write new code.
115+
116+
108117
.. c:function:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value)
109118
110119
Return the first index *i* for which ``o[i] == value``. On error, return

Doc/c-api/sys.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,7 @@ Process Control
426426
function registered last is called first. Each cleanup function will be called
427427
at most once. Since Python's internal finalization will have completed before
428428
the cleanup function, no Python APIs should be called by *func*.
429+
430+
.. seealso::
431+
432+
:c:func:`PyUnstable_AtExit` for passing a ``void *data`` argument.

Doc/c-api/weakref.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ as much as it can.
8888
Use :c:func:`PyWeakref_GetRef` instead.
8989
9090
91+
.. c:function:: int PyWeakref_IsDead(PyObject *ref)
92+
93+
Test if the weak reference *ref* is dead. Returns 1 if the reference is
94+
dead, 0 if it is alive, and -1 with an error set if *ref* is not a weak
95+
reference object.
96+
97+
.. versionadded:: 3.14
98+
99+
91100
.. c:function:: void PyObject_ClearWeakRefs(PyObject *object)
92101
93102
This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler

0 commit comments

Comments
 (0)