Skip to content

Commit ae431d1

Browse files
authored
Merge branch 'main' into main
2 parents 813cf20 + 3364e7e commit ae431d1

File tree

293 files changed

+8188
-3368
lines changed

Some content is hidden

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

293 files changed

+8188
-3368
lines changed

.github/CODEOWNERS

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,19 +427,19 @@ Lib/dataclasses.py @ericvsmith
427427
Lib/test/test_dataclasses/ @ericvsmith
428428

429429
# Dates and times
430-
Doc/**/*time.rst @pganssle @abalkin @StanFromIreland
430+
Doc/**/*time.rst @pganssle @StanFromIreland
431431
Doc/library/datetime-* @pganssle @StanFromIreland
432432
Doc/library/zoneinfo.rst @pganssle @StanFromIreland
433-
Include/datetime.h @pganssle @abalkin @StanFromIreland
434-
Include/internal/pycore_time.h @pganssle @abalkin @StanFromIreland
433+
Include/datetime.h @pganssle @StanFromIreland
434+
Include/internal/pycore_time.h @pganssle @StanFromIreland
435435
Lib/test/test_zoneinfo/ @pganssle @StanFromIreland
436436
Lib/zoneinfo/ @pganssle @StanFromIreland
437-
Lib/*time.py @pganssle @abalkin @StanFromIreland
438-
Lib/test/datetimetester.py @pganssle @abalkin @StanFromIreland
439-
Lib/test/test_*time.py @pganssle @abalkin @StanFromIreland
437+
Lib/*time.py @pganssle @StanFromIreland
438+
Lib/test/datetimetester.py @pganssle @StanFromIreland
439+
Lib/test/test_*time.py @pganssle @StanFromIreland
440440
Modules/*zoneinfo* @pganssle @StanFromIreland
441-
Modules/*time* @pganssle @abalkin @StanFromIreland
442-
Python/pytime.c @pganssle @abalkin @StanFromIreland
441+
Modules/*time* @pganssle @StanFromIreland
442+
Python/pytime.c @pganssle @StanFromIreland
443443

444444
# Dbm
445445
Doc/library/dbm.rst @corona10 @erlend-aasland @serhiy-storchaka

.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/faq/programming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ Performance
10741074
My program is too slow. How do I speed it up?
10751075
---------------------------------------------
10761076

1077-
That's a tough one, in general. First, here is list of things to
1077+
That's a tough one, in general. First, here is a list of things to
10781078
remember before diving further:
10791079

10801080
* Performance characteristics vary across Python implementations. This FAQ

Doc/howto/enum.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ The complete :class:`!Weekday` enum now looks like this::
105105

106106
Now we can find out what today is! Observe::
107107

108-
>>> from datetime import date
109-
>>> Weekday.from_date(date.today()) # doctest: +SKIP
108+
>>> import datetime as dt
109+
>>> Weekday.from_date(dt.date.today()) # doctest: +SKIP
110110
<Weekday.TUESDAY: 2>
111111

112112
Of course, if you're reading this on some other day, you'll see that day instead.
@@ -1480,8 +1480,8 @@ TimePeriod
14801480

14811481
An example to show the :attr:`~Enum._ignore_` attribute in use::
14821482

1483-
>>> from datetime import timedelta
1484-
>>> class Period(timedelta, Enum):
1483+
>>> import datetime as dt
1484+
>>> class Period(dt.timedelta, Enum):
14851485
... "different lengths of time"
14861486
... _ignore_ = 'Period i'
14871487
... Period = vars()

Doc/howto/logging-cookbook.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,10 +1549,10 @@ to this (remembering to first import :mod:`concurrent.futures`)::
15491549
for i in range(10):
15501550
executor.submit(worker_process, queue, worker_configurer)
15511551

1552-
Deploying Web applications using Gunicorn and uWSGI
1552+
Deploying web applications using Gunicorn and uWSGI
15531553
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15541554

1555-
When deploying Web applications using `Gunicorn <https://gunicorn.org/>`_ or `uWSGI
1555+
When deploying web applications using `Gunicorn <https://gunicorn.org/>`_ or `uWSGI
15561556
<https://uwsgi-docs.readthedocs.io/en/latest/>`_ (or similar), multiple worker
15571557
processes are created to handle client requests. In such environments, avoid creating
15581558
file-based handlers directly in your web application. Instead, use a
@@ -3616,7 +3616,6 @@ detailed information.
36163616

36173617
.. code-block:: python3
36183618

3619-
import datetime
36203619
import logging
36213620
import random
36223621
import sys
@@ -3851,15 +3850,15 @@ Logging to syslog with RFC5424 support
38513850
Although :rfc:`5424` dates from 2009, most syslog servers are configured by default to
38523851
use the older :rfc:`3164`, which hails from 2001. When ``logging`` was added to Python
38533852
in 2003, it supported the earlier (and only existing) protocol at the time. Since
3854-
RFC5424 came out, as there has not been widespread deployment of it in syslog
3853+
RFC 5424 came out, as there has not been widespread deployment of it in syslog
38553854
servers, the :class:`~logging.handlers.SysLogHandler` functionality has not been
38563855
updated.
38573856

38583857
RFC 5424 contains some useful features such as support for structured data, and if you
38593858
need to be able to log to a syslog server with support for it, you can do so with a
38603859
subclassed handler which looks something like this::
38613860

3862-
import datetime
3861+
import datetime as dt
38633862
import logging.handlers
38643863
import re
38653864
import socket
@@ -3877,7 +3876,7 @@ subclassed handler which looks something like this::
38773876

38783877
def format(self, record):
38793878
version = 1
3880-
asctime = datetime.datetime.fromtimestamp(record.created).isoformat()
3879+
asctime = dt.datetime.fromtimestamp(record.created).isoformat()
38813880
m = self.tz_offset.match(time.strftime('%z'))
38823881
has_offset = False
38833882
if m and time.timezone:

0 commit comments

Comments
 (0)