Skip to content

Commit 48f3e27

Browse files
Merge branch 'main' into math-log-int-like-overflow
2 parents 6d10cc6 + 4b9e10d commit 48f3e27

File tree

393 files changed

+12373
-7364
lines changed

Some content is hidden

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

393 files changed

+12373
-7364
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV WASI_SDK_VERSION=21
66
ENV WASI_SDK_PATH=/opt/wasi-sdk
77

88
ENV WASMTIME_HOME=/opt/wasmtime
9-
ENV WASMTIME_VERSION=18.0.3
9+
ENV WASMTIME_VERSION=22.0.0
1010
ENV WASMTIME_CPU_ARCH=x86_64
1111

1212
RUN dnf -y --nodocs --setopt=install_weak_deps=False install /usr/bin/{blurb,clang,curl,git,ln,tar,xz} 'dnf-command(builddep)' && \

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Include/internal/pycore_freelist.h @ericsnowcurrently
7272
Include/internal/pycore_global_objects.h @ericsnowcurrently
7373
Include/internal/pycore_obmalloc.h @ericsnowcurrently
7474
Include/internal/pycore_pymem.h @ericsnowcurrently
75+
Include/internal/pycore_stackref.h @Fidget-Spinner
7576
Modules/main.c @ericsnowcurrently
7677
Programs/_bootstrap_python.c @ericsnowcurrently
7778
Programs/python.c @ericsnowcurrently

.github/workflows/reusable-wasi.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
timeout-minutes: 60
1212
runs-on: ubuntu-22.04
1313
env:
14-
WASMTIME_VERSION: 18.0.3
14+
WASMTIME_VERSION: 22.0.0
1515
WASI_SDK_VERSION: 21
1616
WASI_SDK_PATH: /opt/wasi-sdk
1717
CROSS_BUILD_PYTHON: cross-build/build
@@ -20,9 +20,9 @@ jobs:
2020
- uses: actions/checkout@v4
2121
# No problem resolver registered as one doesn't currently exist for Clang.
2222
- name: "Install wasmtime"
23-
uses: jcbhmr/setup-wasmtime@v2
23+
uses: bytecodealliance/actions/wasmtime/setup@v1
2424
with:
25-
wasmtime-version: ${{ env.WASMTIME_VERSION }}
25+
version: ${{ env.WASMTIME_VERSION }}
2626
- name: "Restore WASI SDK"
2727
id: cache-wasi-sdk
2828
uses: actions/cache@v4
@@ -50,8 +50,10 @@ jobs:
5050
uses: actions/cache@v4
5151
with:
5252
path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
53-
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
54-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}-${{ env.pythonLocation }}
53+
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python.
54+
# Include the hash of `Tools/wasm/wasi.py` as it may change the environment variables.
55+
# (Make sure to keep the key in sync with the other config.cache step below.)
56+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
5557
- name: "Configure build Python"
5658
run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
5759
- name: "Make build Python"
@@ -60,8 +62,8 @@ jobs:
6062
uses: actions/cache@v4
6163
with:
6264
path: ${{ env.CROSS_BUILD_WASI }}/config.cache
63-
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
64-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}-${{ inputs.config_hash }}-${{ env.pythonLocation }}
65+
# Should be kept in sync with the other config.cache step above.
66+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
6567
- name: "Configure host"
6668
# `--with-pydebug` inferred from configure-build-python
6769
run: python3 Tools/wasm/wasi.py configure-host -- --config-cache

Doc/c-api/cell.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Cell objects are not likely to be useful elsewhere.
3939
4040
.. c:function:: PyObject* PyCell_Get(PyObject *cell)
4141
42-
Return the contents of the cell *cell*.
42+
Return the contents of the cell *cell*, which can be ``NULL``.
43+
If *cell* is not a cell object, returns ``NULL`` with an exception set.
4344
4445
4546
.. c:function:: PyObject* PyCell_GET(PyObject *cell)
@@ -52,8 +53,10 @@ Cell objects are not likely to be useful elsewhere.
5253
5354
Set the contents of the cell object *cell* to *value*. This releases the
5455
reference to any current content of the cell. *value* may be ``NULL``. *cell*
55-
must be non-``NULL``; if it is not a cell object, ``-1`` will be returned. On
56-
success, ``0`` will be returned.
56+
must be non-``NULL``.
57+
58+
On success, return ``0``.
59+
If *cell* is not a cell object, set an exception and return ``-1``.
5760
5861
5962
.. c:function:: void PyCell_SET(PyObject *cell, PyObject *value)

Doc/c-api/dict.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Dictionary Objects
156156
157157
.. c:function:: int PyDict_GetItemStringRef(PyObject *p, const char *key, PyObject **result)
158158
159-
Similar than :c:func:`PyDict_GetItemRef`, but *key* is specified as a
159+
Similar to :c:func:`PyDict_GetItemRef`, but *key* is specified as a
160160
:c:expr:`const char*` UTF-8 encoded bytes string, rather than a
161161
:c:expr:`PyObject*`.
162162
@@ -206,7 +206,7 @@ Dictionary Objects
206206
``NULL``, and return ``0``.
207207
- On error, raise an exception and return ``-1``.
208208
209-
This is similar to :meth:`dict.pop`, but without the default value and
209+
Similar to :meth:`dict.pop`, but without the default value and
210210
not raising :exc:`KeyError` if the key missing.
211211
212212
.. versionadded:: 3.13

Doc/c-api/long.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,13 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
405405
406406
Passing zero to *n_bytes* will return the size of a buffer that would
407407
be large enough to hold the value. This may be larger than technically
408-
necessary, but not unreasonably so.
408+
necessary, but not unreasonably so. If *n_bytes=0*, *buffer* may be
409+
``NULL``.
409410
410411
.. note::
411412
412413
Passing *n_bytes=0* to this function is not an accurate way to determine
413-
the bit length of a value.
414-
415-
If *n_bytes=0*, *buffer* may be ``NULL``.
414+
the bit length of the value.
416415
417416
To get at the entire Python value of an unknown size, the function can be
418417
called twice: first to determine the buffer size, then to fill it::
@@ -462,6 +461,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
462461
.. c:macro:: Py_ASNATIVEBYTES_NATIVE_ENDIAN ``3``
463462
.. c:macro:: Py_ASNATIVEBYTES_UNSIGNED_BUFFER ``4``
464463
.. c:macro:: Py_ASNATIVEBYTES_REJECT_NEGATIVE ``8``
464+
.. c:macro:: Py_ASNATIVEBYTES_ALLOW_INDEX ``16``
465465
============================================= ======
466466
467467
Specifying ``Py_ASNATIVEBYTES_NATIVE_ENDIAN`` will override any other endian
@@ -483,6 +483,13 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
483483
provided there is enough space for at least one sign bit, regardless of
484484
whether ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` was specified.
485485
486+
If ``Py_ASNATIVEBYTES_ALLOW_INDEX`` is specified and a non-integer value is
487+
passed, its :meth:`~object.__index__` method will be called first. This may
488+
result in Python code executing and other threads being allowed to run, which
489+
could cause changes to other objects or values in use. When *flags* is
490+
``-1``, this option is not set, and non-integer values will raise
491+
:exc:`TypeError`.
492+
486493
.. note::
487494
488495
With the default *flags* (``-1``, or *UNSIGNED_BUFFER* without

Doc/c-api/module.rst

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Module Objects
4343
to ``None``); the caller is responsible for providing a :attr:`__file__`
4444
attribute.
4545
46+
Return ``NULL`` with an exception set on error.
47+
4648
.. versionadded:: 3.3
4749
4850
.. versionchanged:: 3.4
@@ -265,6 +267,8 @@ of the following two module creation functions:
265267
API version *module_api_version*. If that version does not match the version
266268
of the running interpreter, a :exc:`RuntimeWarning` is emitted.
267269
270+
Return ``NULL`` with an exception set on error.
271+
268272
.. note::
269273
270274
Most uses of this function should be using :c:func:`PyModule_Create`
@@ -461,6 +465,8 @@ objects dynamically. Note that both ``PyModule_FromDefAndSpec`` and
461465
If that version does not match the version of the running interpreter,
462466
a :exc:`RuntimeWarning` is emitted.
463467
468+
Return ``NULL`` with an exception set on error.
469+
464470
.. note::
465471
466472
Most uses of this function should be using :c:func:`PyModule_FromDefAndSpec`
@@ -601,23 +607,24 @@ state:
601607
.. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
602608
603609
Add an integer constant to *module* as *name*. This convenience function can be
604-
used from the module's initialization function. Return ``-1`` on error, ``0`` on
605-
success.
610+
used from the module's initialization function.
611+
Return ``-1`` with an exception set on error, ``0`` on success.
606612
607613
608614
.. c:function:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
609615
610616
Add a string constant to *module* as *name*. This convenience function can be
611617
used from the module's initialization function. The string *value* must be
612-
``NULL``-terminated. Return ``-1`` on error, ``0`` on success.
618+
``NULL``-terminated.
619+
Return ``-1`` with an exception set on error, ``0`` on success.
613620
614621
615622
.. c:macro:: PyModule_AddIntMacro(module, macro)
616623
617624
Add an int constant to *module*. The name and the value are taken from
618625
*macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int
619626
constant *AF_INET* with the value of *AF_INET* to *module*.
620-
Return ``-1`` on error, ``0`` on success.
627+
Return ``-1`` with an exception set on error, ``0`` on success.
621628
622629
623630
.. c:macro:: PyModule_AddStringMacro(module, macro)
@@ -630,7 +637,7 @@ state:
630637
The type object is finalized by calling internally :c:func:`PyType_Ready`.
631638
The name of the type object is taken from the last component of
632639
:c:member:`~PyTypeObject.tp_name` after dot.
633-
Return ``-1`` on error, ``0`` on success.
640+
Return ``-1`` with an exception set on error, ``0`` on success.
634641
635642
.. versionadded:: 3.9
636643
@@ -643,7 +650,7 @@ state:
643650
import machinery assumes the module does not support running without the
644651
GIL. This function is only available in Python builds configured with
645652
:option:`--disable-gil`.
646-
Return ``-1`` on error, ``0`` on success.
653+
Return ``-1`` with an exception set on error, ``0`` on success.
647654
648655
.. versionadded:: 3.13
649656
@@ -682,14 +689,14 @@ since multiple such modules can be created from a single definition.
682689
683690
The caller must hold the GIL.
684691
685-
Return 0 on success or -1 on failure.
692+
Return ``-1`` with an exception set on error, ``0`` on success.
686693
687694
.. versionadded:: 3.3
688695
689696
.. c:function:: int PyState_RemoveModule(PyModuleDef *def)
690697
691698
Removes the module object created from *def* from the interpreter state.
692-
Return 0 on success or -1 on failure.
699+
Return ``-1`` with an exception set on error, ``0`` on success.
693700
694701
The caller must hold the GIL.
695702

Doc/c-api/object.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Object Protocol
5252
5353
The reference is borrowed from the interpreter, and is valid until the
5454
interpreter finalization.
55+
5556
.. versionadded:: 3.13
5657
5758

Doc/c-api/slice.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ Slice Objects
2323
Return a new slice object with the given values. The *start*, *stop*, and
2424
*step* parameters are used as the values of the slice object attributes of
2525
the same names. Any of the values may be ``NULL``, in which case the
26-
``None`` will be used for the corresponding attribute. Return ``NULL`` if
26+
``None`` will be used for the corresponding attribute.
27+
28+
Return ``NULL`` with an exception set if
2729
the new object could not be allocated.
2830
2931
@@ -52,7 +54,7 @@ Slice Objects
5254
of bounds indices are clipped in a manner consistent with the handling of
5355
normal slices.
5456
55-
Returns ``0`` on success and ``-1`` on error with exception set.
57+
Return ``0`` on success and ``-1`` on error with an exception set.
5658
5759
.. note::
5860
This function is considered not safe for resizable sequences.
@@ -95,7 +97,7 @@ Slice Objects
9597
``PY_SSIZE_T_MIN`` to ``PY_SSIZE_T_MIN``, and silently boost the step
9698
values less than ``-PY_SSIZE_T_MAX`` to ``-PY_SSIZE_T_MAX``.
9799
98-
Return ``-1`` on error, ``0`` on success.
100+
Return ``-1`` with an exception set on error, ``0`` on success.
99101
100102
.. versionadded:: 3.6.1
101103

Doc/c-api/typeobj.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
15921592
weak references to the type object itself.
15931593

15941594
It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit and
1595-
:c:member:`~PyTypeObject.tp_weaklist`.
1595+
:c:member:`~PyTypeObject.tp_weaklistoffset`.
15961596

15971597
**Inheritance:**
15981598

@@ -1604,7 +1604,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
16041604
**Default:**
16051605

16061606
If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the
1607-
:c:member:`~PyTypeObject.tp_dict` field, then
1607+
:c:member:`~PyTypeObject.tp_flags` field, then
16081608
:c:member:`~PyTypeObject.tp_weaklistoffset` will be set to a negative value,
16091609
to indicate that it is unsafe to use this field.
16101610

0 commit comments

Comments
 (0)