Skip to content

Commit 3e05fa3

Browse files
Merge branch 'main' of github.com:python/cpython into fix-gh-138577
* 'main' of github.com:python/cpython: gh-146197: Run -m test.pythoninfo on the Emscripten CI (#146332) gh-146325: Use `test.support.requires_fork` in test_fastpath_cache_cleared_in_forked_child (#146330) gh-146197: Add Emscripten to CI (#146198) gh-143387: Raise an exception instead of returning None when metadata file is missing. (#146234) gh-108907: ctypes: Document _type_ codes (GH-145837) gh-146175: Soft-deprecate outdated macros; convert internal usage (GH-146178) gh-146056: Rework ref counting in treebuilder_handle_end() (#146167) Add a warning about untrusted input to `configparser` docs (#146276) gh-145264: Do not ignore excess Base64 data after the first padded quad (GH-145267) gh-146308: Fix error handling issues in _remote_debugging module (#146309) gh-146192: Add base32 support to binascii (GH-146193) gh-135953: Properly obtain main thread identifier in Gecko Collector (#146045) gh-143414: Implement unique reference tracking for JIT, optimize unpacking of such tuples (GH-144300) gh-146261: Fix bug in `_Py_uop_sym_set_func_version` (GH-146291) gh-145144: Add more tests for UserList, UserDict, etc (GH-145145) gh-143959: Fix test_datetime if _datetime is unavailable (GH-145248) gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) gh-140049: Colorize exception notes in `traceback.py` (#140051) Update docs for gh-146056 (GH-146213)
2 parents e1e4aa3 + a57209e commit 3e05fa3

File tree

81 files changed

+3553
-1269
lines changed

Some content is hidden

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

81 files changed

+3553
-1269
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ jobs:
371371
- name: Build and test
372372
run: python3 Apple ci iOS --fast-ci --simulator 'iPhone SE (3rd generation),OS=17.5'
373373

374+
build-emscripten:
375+
name: 'Emscripten'
376+
needs: build-context
377+
if: needs.build-context.outputs.run-emscripten == 'true'
378+
uses: ./.github/workflows/reusable-emscripten.yml
379+
374380
build-wasi:
375381
name: 'WASI'
376382
needs: build-context
@@ -650,6 +656,7 @@ jobs:
650656
- build-ubuntu
651657
- build-ubuntu-ssltests
652658
- build-ios
659+
- build-emscripten
653660
- build-wasi
654661
- test-hypothesis
655662
- build-asan
@@ -664,6 +671,7 @@ jobs:
664671
with:
665672
allowed-failures: >-
666673
build-android,
674+
build-emscripten,
667675
build-windows-msi,
668676
build-ubuntu-ssltests,
669677
test-hypothesis,
@@ -706,5 +714,6 @@ jobs:
706714
}}
707715
${{ !fromJSON(needs.build-context.outputs.run-android) && 'build-android,' || '' }}
708716
${{ !fromJSON(needs.build-context.outputs.run-ios) && 'build-ios,' || '' }}
717+
${{ !fromJSON(needs.build-context.outputs.run-emscripten) && 'build-emscripten,' || '' }}
709718
${{ !fromJSON(needs.build-context.outputs.run-wasi) && 'build-wasi,' || '' }}
710719
jobs: ${{ toJSON(needs) }}

.github/workflows/reusable-context.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ on: # yamllint disable-line rule:truthy
4141
run-ubuntu:
4242
description: Whether to run the Ubuntu tests
4343
value: ${{ jobs.compute-changes.outputs.run-ubuntu }} # bool
44+
run-emscripten:
45+
description: Whether to run the Emscripten tests
46+
value: ${{ jobs.compute-changes.outputs.run-emscripten }} # bool
4447
run-wasi:
4548
description: Whether to run the WASI tests
4649
value: ${{ jobs.compute-changes.outputs.run-wasi }} # bool
@@ -65,6 +68,7 @@ jobs:
6568
run-macos: ${{ steps.changes.outputs.run-macos }}
6669
run-tests: ${{ steps.changes.outputs.run-tests }}
6770
run-ubuntu: ${{ steps.changes.outputs.run-ubuntu }}
71+
run-emscripten: ${{ steps.changes.outputs.run-emscripten }}
6872
run-wasi: ${{ steps.changes.outputs.run-wasi }}
6973
run-windows-msi: ${{ steps.changes.outputs.run-windows-msi }}
7074
run-windows-tests: ${{ steps.changes.outputs.run-windows-tests }}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Reusable Emscripten
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
FORCE_COLOR: 1
8+
9+
jobs:
10+
build-emscripten-reusable:
11+
name: 'build and test'
12+
runs-on: ubuntu-24.04
13+
timeout-minutes: 60
14+
steps:
15+
- uses: actions/checkout@v6
16+
with:
17+
persist-credentials: false
18+
- name: "Read Emscripten config"
19+
id: emscripten-config
20+
shell: python
21+
run: |
22+
import hashlib
23+
import json
24+
import os
25+
import tomllib
26+
from pathlib import Path
27+
28+
config = tomllib.loads(Path("Platforms/emscripten/config.toml").read_text())
29+
h = hashlib.sha256()
30+
h.update(json.dumps(config["dependencies"], sort_keys=True).encode())
31+
h.update(Path("Platforms/emscripten/make_libffi.sh").read_bytes())
32+
h.update(b'1') # Update to explicitly bust cache
33+
emsdk_cache = Path(os.environ["RUNNER_TEMP"]) / "emsdk-cache"
34+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
35+
f.write(f"emscripten-version={config['emscripten-version']}\n")
36+
f.write(f"node-version={config['node-version']}\n")
37+
f.write(f"deps-hash={h.hexdigest()}\n")
38+
with open(os.environ["GITHUB_ENV"], "a") as f:
39+
f.write(f"EMSDK_CACHE={emsdk_cache}\n")
40+
- name: "Install Node.js"
41+
uses: actions/setup-node@v6
42+
with:
43+
node-version: ${{ steps.emscripten-config.outputs.node-version }}
44+
- name: "Cache Emscripten SDK"
45+
id: emsdk-cache
46+
uses: actions/cache@v5
47+
with:
48+
path: ${{ env.EMSDK_CACHE }}
49+
key: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }}-${{ steps.emscripten-config.outputs.deps-hash }}
50+
restore-keys: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }}
51+
- name: "Install Python"
52+
uses: actions/setup-python@v6
53+
with:
54+
python-version: '3.x'
55+
- name: "Runner image version"
56+
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
57+
- name: "Install Emscripten"
58+
run: python3 Platforms/emscripten install-emscripten
59+
- name: "Configure build Python"
60+
run: python3 Platforms/emscripten configure-build-python -- --config-cache --with-pydebug
61+
- name: "Make build Python"
62+
run: python3 Platforms/emscripten make-build-python
63+
- name: "Make dependencies"
64+
run: >-
65+
python3 Platforms/emscripten make-dependencies
66+
${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }}
67+
- name: "Configure host Python"
68+
run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache
69+
- name: "Make host Python"
70+
run: python3 Platforms/emscripten make-host
71+
- name: "Display build info"
72+
run: python3 Platforms/emscripten run --pythoninfo
73+
- name: "Test"
74+
run: python3 Platforms/emscripten run --test

Doc/c-api/intro.rst

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,26 @@ to the C language.
526526
Outdated macros
527527
---------------
528528

529-
The following macros have been used to features that have been standardized
530-
in C11.
529+
The following :term:`soft deprecated` macros have been used to features that
530+
have been standardized in C11 (or previous standards).
531531

532532
.. c:macro:: Py_ALIGNED(num)
533533
534-
Specify alignment to *num* bytes on compilers that support it.
534+
On some GCC-like compilers, specify alignment to *num* bytes.
535+
This does nothing on other compilers.
535536

536-
Consider using the C11 standard ``_Alignas`` specifier over this macro.
537+
Use the standard ``alignas`` specifier rather than this macro.
538+
539+
.. deprecated:: next
540+
The macro is :term:`soft deprecated`.
541+
542+
.. c:macro:: PY_FORMAT_SIZE_T
543+
544+
The :c:func:`printf` formatting modifier for :c:type:`size_t`.
545+
Use ``"z"`` directly instead.
546+
547+
.. deprecated:: next
548+
The macro is :term:`soft deprecated`.
537549

538550
.. c:macro:: Py_LL(number)
539551
Py_ULL(number)
@@ -546,6 +558,38 @@ in C11.
546558
547559
Consider using the C99 standard suffixes ``LL`` and ``LLU`` directly.
548560
561+
.. deprecated:: next
562+
The macro is :term:`soft deprecated`.
563+
564+
.. c:macro:: PY_LONG_LONG
565+
PY_INT32_T
566+
PY_UINT32_T
567+
PY_INT64_T
568+
PY_UINT64_T
569+
570+
Aliases for the types :c:type:`!long long`, :c:type:`!int32_t`,
571+
:c:type:`!uint32_t`. :c:type:`!int64_t` and :c:type:`!uint64_t`,
572+
respectively.
573+
Historically, these types needed compiler-specific extensions.
574+
575+
.. deprecated:: next
576+
These macros are :term:`soft deprecated`.
577+
578+
.. c:macro:: PY_LLONG_MIN
579+
PY_LLONG_MAX
580+
PY_ULLONG_MAX
581+
PY_SIZE_MAX
582+
583+
Aliases for the values :c:macro:`!LLONG_MIN`, :c:macro:`!LLONG_MAX`,
584+
:c:macro:`!ULLONG_MAX`, and :c:macro:`!SIZE_MAX`, respectively.
585+
Use these standard names instead.
586+
587+
The required header, ``<limits.h>``,
588+
:ref:`is included <capi-system-includes>` in ``Python.h``.
589+
590+
.. deprecated:: next
591+
These macros are :term:`soft deprecated`.
592+
549593
.. c:macro:: Py_MEMCPY(dest, src, n)
550594
551595
This is a :term:`soft deprecated` alias to :c:func:`!memcpy`.
@@ -554,6 +598,25 @@ in C11.
554598
.. deprecated:: 3.14
555599
The macro is :term:`soft deprecated`.
556600
601+
.. c:macro:: Py_UNICODE_SIZE
602+
603+
Size of the :c:type:`!wchar_t` type.
604+
Use ``sizeof(wchar_t)`` or ``WCHAR_WIDTH/8`` instead.
605+
606+
The required header for the latter, ``<limits.h>``,
607+
:ref:`is included <capi-system-includes>` in ``Python.h``.
608+
609+
.. deprecated:: next
610+
The macro is :term:`soft deprecated`.
611+
612+
.. c:macro:: Py_UNICODE_WIDE
613+
614+
Defined if ``wchar_t`` can hold a Unicode character (UCS-4).
615+
Use ``sizeof(wchar_t) >= 4`` instead
616+
617+
.. deprecated:: next
618+
The macro is :term:`soft deprecated`.
619+
557620
.. c:macro:: Py_VA_COPY
558621
559622
This is a :term:`soft deprecated` alias to the C99-standard ``va_copy``
@@ -564,6 +627,9 @@ in C11.
564627
.. versionchanged:: 3.6
565628
This is now an alias to ``va_copy``.
566629
630+
.. deprecated:: next
631+
The macro is :term:`soft deprecated`.
632+
567633
568634
.. _api-objects:
569635

Doc/c-api/unicode.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,8 +1855,6 @@ object.
18551855
On success, return ``0``.
18561856
On error, set an exception, leave the writer unchanged, and return ``-1``.
18571857
1858-
.. versionadded:: 3.14
1859-
18601858
.. c:function:: int PyUnicodeWriter_WriteWideChar(PyUnicodeWriter *writer, const wchar_t *str, Py_ssize_t size)
18611859
18621860
Write the wide string *str* into *writer*.
@@ -1892,6 +1890,10 @@ object.
18921890
On success, return ``0``.
18931891
On error, set an exception, leave the writer unchanged, and return ``-1``.
18941892
1893+
.. versionchanged:: 3.14.4
1894+
1895+
Added support for ``NULL``.
1896+
18951897
.. c:function:: int PyUnicodeWriter_WriteSubstring(PyUnicodeWriter *writer, PyObject *str, Py_ssize_t start, Py_ssize_t end)
18961898
18971899
Write the substring ``str[start:end]`` into *writer*.

Doc/deprecations/c-api-pending-removal-in-3.15.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Pending removal in Python 3.15
77
Use :c:func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project
88
<https://github.com/python/pythoncapi-compat/>`__ can be used to get
99
:c:func:`PyWeakref_GetRef` on Python 3.12 and older.
10-
* :c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro:
11-
Use :c:type:`wchar_t` instead.
1210
* :c:func:`!PyUnicode_AsDecodedObject`:
1311
Use :c:func:`PyCodec_Decode` instead.
1412
* :c:func:`!PyUnicode_AsDecodedUnicode`:

Doc/library/array.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ Notes:
6363
(2)
6464
.. versionadded:: 3.13
6565

66+
.. seealso::
67+
68+
The :ref:`ctypes <ctypes-fundamental-data-types>` and
69+
:ref:`struct <format-characters>` modules,
70+
as well as third-party modules like `numpy <https://numpy.org/doc/stable/reference/arrays.interface.html#object.__array_interface__>`__,
71+
use similar -- but slightly different -- type codes.
72+
6673

6774
The actual representation of values is determined by the machine architecture
6875
(strictly speaking, by the C implementation). The actual size can be accessed

Doc/library/binascii.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,38 @@ The :mod:`!binascii` module defines the following functions:
183183
.. versionadded:: 3.15
184184

185185

186+
.. function:: a2b_base32(string, /, *, alphabet=BASE32_ALPHABET)
187+
188+
Convert base32 data back to binary and return the binary data.
189+
190+
Valid base32 data contains characters from the base32 alphabet specified
191+
in :rfc:`4648` in groups of eight (if necessary, the final group is padded
192+
to eight characters with ``=``). Each group encodes 40 bits of binary data
193+
in the range from ``0`` to ``2 ** 40 - 1``, inclusive.
194+
195+
.. note::
196+
This function does not map lowercase characters (which are invalid in
197+
standard base32) to their uppercase counterparts, nor does it
198+
contextually map ``0`` to ``O`` and ``1`` to ``I``/``L`` as :rfc:`4648`
199+
allows.
200+
201+
Optional *alphabet* must be a :class:`bytes` object of length 32 which
202+
specifies an alternative alphabet.
203+
204+
Invalid base32 data will raise :exc:`binascii.Error`.
205+
206+
.. versionadded:: next
207+
208+
.. function:: b2a_base32(data, /, *, alphabet=BASE32_ALPHABET)
209+
210+
Convert binary data to a line of ASCII characters in base32 coding,
211+
as specified in :rfc:`4648`. The return value is the converted line.
212+
213+
Optional *alphabet* must be a :term:`bytes-like object` of length 32 which
214+
specifies an alternative alphabet.
215+
216+
.. versionadded:: next
217+
186218
.. function:: a2b_qp(data, header=False)
187219

188220
Convert a block of quoted-printable data back to binary and return the binary
@@ -327,6 +359,20 @@ The :mod:`!binascii` module defines the following functions:
327359

328360
.. versionadded:: next
329361

362+
.. data:: BASE32_ALPHABET
363+
364+
The Base 32 alphabet according to :rfc:`4648`.
365+
366+
.. versionadded:: next
367+
368+
.. data:: BASE32HEX_ALPHABET
369+
370+
The "Extended Hex" Base 32 alphabet according to :rfc:`4648`.
371+
Data encoded with this alphabet maintains its sort order during bitwise
372+
comparisons.
373+
374+
.. versionadded:: next
375+
330376

331377
.. seealso::
332378

Doc/library/configparser.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ can be customized by end users easily.
2424
This library does *not* interpret or write the value-type prefixes used in
2525
the Windows Registry extended version of INI syntax.
2626

27+
.. warning::
28+
Be cautious when parsing data from untrusted sources. A malicious
29+
INI file may cause the decoder to consume considerable CPU and memory
30+
resources. Limiting the size of data to be parsed is recommended.
31+
2732
.. seealso::
2833

2934
Module :mod:`tomllib`

0 commit comments

Comments
 (0)