Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 10ab5f0

Browse files
authored
Merge branch 'main' into main
2 parents b3aeb06 + f4bc84d commit 10ab5f0

File tree

130 files changed

+2948
-1073
lines changed

Some content is hidden

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

130 files changed

+2948
-1073
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM docker.io/library/fedora:40
22

33
ENV CC=clang
44

5-
ENV WASI_SDK_VERSION=21
5+
ENV WASI_SDK_VERSION=22
66
ENV WASI_SDK_PATH=/opt/wasi-sdk
77

88
ENV WASMTIME_HOME=/opt/wasmtime

.github/workflows/build.yml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,31 @@ jobs:
2727
runs-on: ubuntu-latest
2828
timeout-minutes: 10
2929
outputs:
30+
# Some of the referenced steps set outputs conditionally and there may be
31+
# cases when referencing them evaluates to empty strings. It is nice to
32+
# work with proper booleans so they have to be evaluated through JSON
33+
# conversion in the expressions. However, empty strings used like that
34+
# may trigger all sorts of undefined and hard-to-debug behaviors in
35+
# GitHub Actions CI/CD. To help with this, all of the outputs set here
36+
# that are meant to be used as boolean flags (and not arbitrary strings),
37+
# MUST have fallbacks with default values set. A common pattern would be
38+
# to add ` || false` to all such expressions here, in the output
39+
# definitions. They can then later be safely used through the following
40+
# idiom in job conditionals and other expressions. Here's some examples:
41+
#
42+
# if: fromJSON(needs.check_source.outputs.run-docs)
43+
#
44+
# ${{
45+
# fromJSON(needs.check_source.outputs.run_tests)
46+
# && 'truthy-branch'
47+
# || 'falsy-branch'
48+
# }}
49+
#
3050
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
31-
run_tests: ${{ steps.check.outputs.run_tests }}
32-
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
33-
run_cifuzz: ${{ steps.check.outputs.run_cifuzz }}
34-
config_hash: ${{ steps.config_hash.outputs.hash }}
51+
run_tests: ${{ steps.check.outputs.run_tests || false }}
52+
run_hypothesis: ${{ steps.check.outputs.run_hypothesis || false }}
53+
run_cifuzz: ${{ steps.check.outputs.run_cifuzz || false }}
54+
config_hash: ${{ steps.config_hash.outputs.hash }} # str
3555
steps:
3656
- uses: actions/checkout@v4
3757
- name: Check for source changes
@@ -179,18 +199,24 @@ jobs:
179199
run: make check-c-globals
180200

181201
build_windows:
182-
name: 'Windows'
202+
name: >-
203+
Windows
204+
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
183205
needs: check_source
184-
if: needs.check_source.outputs.run_tests == 'true'
185-
uses: ./.github/workflows/reusable-windows.yml
186-
187-
build_windows_free_threading:
188-
name: 'Windows (free-threading)'
189-
needs: check_source
190-
if: needs.check_source.outputs.run_tests == 'true'
206+
if: fromJSON(needs.check_source.outputs.run_tests)
207+
strategy:
208+
matrix:
209+
arch:
210+
- Win32
211+
- x64
212+
- arm64
213+
free-threading:
214+
- false
215+
- true
191216
uses: ./.github/workflows/reusable-windows.yml
192217
with:
193-
free-threading: true
218+
arch: ${{ matrix.arch }}
219+
free-threading: ${{ matrix.free-threading }}
194220

195221
build_macos:
196222
name: 'macOS'
@@ -556,7 +582,6 @@ jobs:
556582
- build_ubuntu_ssltests
557583
- build_wasi
558584
- build_windows
559-
- build_windows_free_threading
560585
- test_hypothesis
561586
- build_asan
562587
- build_tsan
@@ -592,7 +617,6 @@ jobs:
592617
build_ubuntu_ssltests,
593618
build_wasi,
594619
build_windows,
595-
build_windows_free_threading,
596620
build_asan,
597621
build_tsan,
598622
build_tsan_free_threading,

.github/workflows/reusable-wasi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-22.04
1313
env:
1414
WASMTIME_VERSION: 22.0.0
15-
WASI_SDK_VERSION: 21
15+
WASI_SDK_VERSION: 22
1616
WASI_SDK_PATH: /opt/wasi-sdk
1717
CROSS_BUILD_PYTHON: cross-build/build
1818
CROSS_BUILD_WASI: cross-build/wasm32-wasi
Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,45 @@
11
on:
22
workflow_call:
33
inputs:
4+
arch:
5+
description: CPU architecture
6+
required: true
7+
type: string
48
free-threading:
9+
description: Whether to compile CPython in free-threading mode
510
required: false
611
type: boolean
712
default: false
813

9-
jobs:
10-
build_win32:
11-
name: 'build and test (x86)'
12-
runs-on: windows-latest
13-
timeout-minutes: 60
14-
env:
15-
IncludeUwp: 'true'
16-
steps:
17-
- uses: actions/checkout@v4
18-
- name: Build CPython
19-
run: .\PCbuild\build.bat -e -d -v -p Win32 ${{ inputs.free-threading && '--disable-gil' || '' }}
20-
- name: Display build info
21-
run: .\python.bat -m test.pythoninfo
22-
- name: Tests
23-
run: .\PCbuild\rt.bat -p Win32 -d -q --fast-ci ${{ inputs.free-threading && '--disable-gil' || '' }}
14+
env:
15+
IncludeUwp: >-
16+
true
2417
25-
build_win_amd64:
26-
name: 'build and test (x64)'
18+
jobs:
19+
build:
20+
name: >-
21+
build${{ inputs.arch != 'arm64' && ' and test' || '' }}
22+
(${{ inputs.arch }})
2723
runs-on: windows-latest
2824
timeout-minutes: 60
29-
env:
30-
IncludeUwp: 'true'
3125
steps:
3226
- uses: actions/checkout@v4
3327
- name: Register MSVC problem matcher
28+
if: inputs.arch != 'Win32'
3429
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
3530
- name: Build CPython
36-
run: .\PCbuild\build.bat -e -d -v -p x64 ${{ inputs.free-threading && '--disable-gil' || '' }}
31+
run: >-
32+
.\PCbuild\build.bat
33+
-e -d -v
34+
-p ${{ inputs.arch }}
35+
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
3736
- name: Display build info
37+
if: inputs.arch != 'arm64'
3838
run: .\python.bat -m test.pythoninfo
3939
- name: Tests
40-
run: .\PCbuild\rt.bat -p x64 -d -q --fast-ci ${{ inputs.free-threading && '--disable-gil' || '' }}
41-
42-
build_win_arm64:
43-
name: 'build (arm64)'
44-
runs-on: windows-latest
45-
timeout-minutes: 60
46-
env:
47-
IncludeUwp: 'true'
48-
steps:
49-
- uses: actions/checkout@v4
50-
- name: Register MSVC problem matcher
51-
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
52-
- name: Build CPython
53-
run: .\PCbuild\build.bat -e -d -v -p arm64 ${{ inputs.free-threading && '--disable-gil' || '' }}
40+
if: inputs.arch != 'arm64'
41+
run: >-
42+
.\PCbuild\rt.bat
43+
-p ${{ inputs.arch }}
44+
-d -q --fast-ci
45+
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}

Doc/c-api/complex.rst

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ pointers. This is consistent throughout the API.
2525
2626
The C structure which corresponds to the value portion of a Python complex
2727
number object. Most of the functions for dealing with complex number objects
28-
use structures of this type as input or output values, as appropriate. It is
29-
defined as::
28+
use structures of this type as input or output values, as appropriate.
29+
30+
.. c:member:: double real
31+
double imag
32+
33+
The structure is defined as::
3034

3135
typedef struct {
32-
double real;
33-
double imag;
36+
double real;
37+
double imag;
3438
} Py_complex;
3539

3640

@@ -106,11 +110,13 @@ Complex Numbers as Python Objects
106110
.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v)
107111
108112
Create a new Python complex number object from a C :c:type:`Py_complex` value.
113+
Return ``NULL`` with an exception set on error.
109114
110115
111116
.. c:function:: PyObject* PyComplex_FromDoubles(double real, double imag)
112117
113118
Return a new :c:type:`PyComplexObject` object from *real* and *imag*.
119+
Return ``NULL`` with an exception set on error.
114120
115121
116122
.. c:function:: double PyComplex_RealAsDouble(PyObject *op)
@@ -121,7 +127,9 @@ Complex Numbers as Python Objects
121127
:meth:`~object.__complex__` method, this method will first be called to
122128
convert *op* to a Python complex number object. If :meth:`!__complex__` is
123129
not defined then it falls back to call :c:func:`PyFloat_AsDouble` and
124-
returns its result. Upon failure, this method returns ``-1.0``, so one
130+
returns its result.
131+
132+
Upon failure, this method returns ``-1.0`` with an exception set, so one
125133
should call :c:func:`PyErr_Occurred` to check for errors.
126134
127135
.. versionchanged:: 3.13
@@ -135,8 +143,10 @@ Complex Numbers as Python Objects
135143
:meth:`~object.__complex__` method, this method will first be called to
136144
convert *op* to a Python complex number object. If :meth:`!__complex__` is
137145
not defined then it falls back to call :c:func:`PyFloat_AsDouble` and
138-
returns ``0.0`` on success. Upon failure, this method returns ``-1.0``, so
139-
one should call :c:func:`PyErr_Occurred` to check for errors.
146+
returns ``0.0`` on success.
147+
148+
Upon failure, this method returns ``-1.0`` with an exception set, so one
149+
should call :c:func:`PyErr_Occurred` to check for errors.
140150
141151
.. versionchanged:: 3.13
142152
Use :meth:`~object.__complex__` if available.
@@ -149,8 +159,11 @@ Complex Numbers as Python Objects
149159
method, this method will first be called to convert *op* to a Python complex
150160
number object. If :meth:`!__complex__` is not defined then it falls back to
151161
:meth:`~object.__float__`. If :meth:`!__float__` is not defined then it falls back
152-
to :meth:`~object.__index__`. Upon failure, this method returns ``-1.0`` as a real
153-
value.
162+
to :meth:`~object.__index__`.
163+
164+
Upon failure, this method returns :c:type:`Py_complex`
165+
with :c:member:`~Py_complex.real` set to ``-1.0`` and with an exception set, so one
166+
should call :c:func:`PyErr_Occurred` to check for errors.
154167
155168
.. versionchanged:: 3.8
156169
Use :meth:`~object.__index__` if available.

Doc/c-api/list.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ List Objects
3838
.. note::
3939
4040
If *len* is greater than zero, the returned list object's items are
41-
set to ``NULL``. Thus you cannot use abstract API functions such as
42-
:c:func:`PySequence_SetItem` or expose the object to Python code before
43-
setting all items to a real object with :c:func:`PyList_SetItem`.
41+
set to ``NULL``. Thus you cannot use abstract API functions such as
42+
:c:func:`PySequence_SetItem` or expose the object to Python code before
43+
setting all items to a real object with :c:func:`PyList_SetItem` or
44+
:c:func:`PyList_SET_ITEM()`. The following APIs are safe APIs before
45+
the list is fully initialized: :c:func:`PyList_SetItem()` and :c:func:`PyList_SET_ITEM()`.
46+
4447
4548
4649
.. c:function:: Py_ssize_t PyList_Size(PyObject *list)

Doc/c-api/module.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,14 @@ state:
549549
Note that ``Py_XDECREF()`` should be used instead of ``Py_DECREF()`` in
550550
this case, since *obj* can be ``NULL``.
551551
552+
The number of different *name* strings passed to this function
553+
should be kept small, usually by only using statically allocated strings
554+
as *name*.
555+
For names that aren't known at compile time, prefer calling
556+
:c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` directly.
557+
For more details, see :c:func:`PyUnicode_InternFromString`, which may be
558+
used internally to create a key object.
559+
552560
.. versionadded:: 3.10
553561
554562
@@ -610,6 +618,9 @@ state:
610618
used from the module's initialization function.
611619
Return ``-1`` with an exception set on error, ``0`` on success.
612620
621+
This is a convenience function that calls :c:func:`PyLong_FromLong` and
622+
:c:func:`PyModule_AddObjectRef`; see their documentation for details.
623+
613624
614625
.. c:function:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
615626
@@ -618,6 +629,10 @@ state:
618629
``NULL``-terminated.
619630
Return ``-1`` with an exception set on error, ``0`` on success.
620631
632+
This is a convenience function that calls
633+
:c:func:`PyUnicode_InternFromString` and :c:func:`PyModule_AddObjectRef`;
634+
see their documentation for details.
635+
621636
622637
.. c:macro:: PyModule_AddIntMacro(module, macro)
623638

Doc/c-api/object.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ Object Protocol
206206
If *v* is ``NULL``, the attribute is deleted, but this feature is
207207
deprecated in favour of using :c:func:`PyObject_DelAttrString`.
208208
209+
The number of different attribute names passed to this function
210+
should be kept small, usually by using a statically allocated string
211+
as *attr_name*.
212+
For attribute names that aren't known at compile time, prefer calling
213+
:c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` directly.
214+
For more details, see :c:func:`PyUnicode_InternFromString`, which may be
215+
used internally to create a key object.
209216
210217
.. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
211218
@@ -231,6 +238,14 @@ Object Protocol
231238
specified as a :c:expr:`const char*` UTF-8 encoded bytes string,
232239
rather than a :c:expr:`PyObject*`.
233240
241+
The number of different attribute names passed to this function
242+
should be kept small, usually by using a statically allocated string
243+
as *attr_name*.
244+
For attribute names that aren't known at compile time, prefer calling
245+
:c:func:`PyUnicode_FromString` and :c:func:`PyObject_DelAttr` directly.
246+
For more details, see :c:func:`PyUnicode_InternFromString`, which may be
247+
used internally to create a key object for lookup.
248+
234249
235250
.. c:function:: PyObject* PyObject_GenericGetDict(PyObject *o, void *context)
236251

Doc/c-api/unicode.rst

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,18 +1490,43 @@ They all return ``NULL`` or ``-1`` if an exception occurs.
14901490
existing interned string that is the same as :c:expr:`*p_unicode`, it sets :c:expr:`*p_unicode` to
14911491
it (releasing the reference to the old string object and creating a new
14921492
:term:`strong reference` to the interned string object), otherwise it leaves
1493-
:c:expr:`*p_unicode` alone and interns it (creating a new :term:`strong reference`).
1493+
:c:expr:`*p_unicode` alone and interns it.
1494+
14941495
(Clarification: even though there is a lot of talk about references, think
1495-
of this function as reference-neutral; you own the object after the call
1496-
if and only if you owned it before the call.)
1496+
of this function as reference-neutral. You must own the object you pass in;
1497+
after the call you no longer own the passed-in reference, but you newly own
1498+
the result.)
1499+
1500+
This function never raises an exception.
1501+
On error, it leaves its argument unchanged without interning it.
1502+
1503+
Instances of subclasses of :py:class:`str` may not be interned, that is,
1504+
:c:expr:`PyUnicode_CheckExact(*p_unicode)` must be true. If it is not,
1505+
then -- as with any other error -- the argument is left unchanged.
1506+
1507+
Note that interned strings are not “immortal”.
1508+
You must keep a reference to the result to benefit from interning.
14971509
14981510
14991511
.. c:function:: PyObject* PyUnicode_InternFromString(const char *str)
15001512
15011513
A combination of :c:func:`PyUnicode_FromString` and
1502-
:c:func:`PyUnicode_InternInPlace`, returning either a new Unicode string
1503-
object that has been interned, or a new ("owned") reference to an earlier
1504-
interned string object with the same value.
1514+
:c:func:`PyUnicode_InternInPlace`, meant for statically allocated strings.
1515+
1516+
Return a new ("owned") reference to either a new Unicode string object
1517+
that has been interned, or an earlier interned string object with the
1518+
same value.
1519+
1520+
Python may keep a reference to the result, or make it :term:`immortal`,
1521+
preventing it from being garbage-collected promptly.
1522+
For interning an unbounded number of different strings, such as ones coming
1523+
from user input, prefer calling :c:func:`PyUnicode_FromString` and
1524+
:c:func:`PyUnicode_InternInPlace` directly.
1525+
1526+
.. impl-detail::
1527+
1528+
Strings interned this way are made :term:`immortal`.
1529+
15051530
15061531
PyUnicodeWriter
15071532
^^^^^^^^^^^^^^^

Doc/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@
347347
}
348348

349349
# This 'Last updated on:' timestamp is inserted at the bottom of every page.
350-
html_last_updated_fmt = time.strftime('%b %d, %Y (%H:%M UTC)', time.gmtime())
350+
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
351+
html_last_updated_fmt = time.strftime('%b %d, %Y (%H:%M UTC)', time.gmtime(html_time))
351352

352353
# Path to find HTML templates.
353354
templates_path = ['tools/templates']

0 commit comments

Comments
 (0)