Skip to content

Commit 6bedc4b

Browse files
authored
Merge branch 'main' into fix/locale-set-object-exception-126742
2 parents 45442c3 + 84ff131 commit 6bedc4b

File tree

21 files changed

+249
-103
lines changed

21 files changed

+249
-103
lines changed

Doc/c-api/stable.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Limited C API
6666

6767
Python 3.2 introduced the *Limited API*, a subset of Python's C API.
6868
Extensions that only use the Limited API can be
69-
compiled once and work with multiple versions of Python.
69+
compiled once and be loaded on multiple versions of Python.
7070
Contents of the Limited API are :ref:`listed below <limited-api-list>`.
7171

7272
.. c:macro:: Py_LIMITED_API
@@ -76,7 +76,7 @@ Contents of the Limited API are :ref:`listed below <limited-api-list>`.
7676

7777
Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX`
7878
corresponding to the lowest Python version your extension supports.
79-
The extension will work without recompilation with all Python 3 releases
79+
The extension will be ABI-compatible with all Python 3 releases
8080
from the specified one onward, and can use Limited API introduced up to that
8181
version.
8282

@@ -94,7 +94,15 @@ Stable ABI
9494
----------
9595

9696
To enable this, Python provides a *Stable ABI*: a set of symbols that will
97-
remain compatible across Python 3.x versions.
97+
remain ABI-compatible across Python 3.x versions.
98+
99+
.. note::
100+
101+
The Stable ABI prevents ABI issues, like linker errors due to missing
102+
symbols or data corruption due to changes in structure layouts or function
103+
signatures.
104+
However, other changes in Python can change the *behavior* of extensions.
105+
See Python's Backwards Compatibility Policy (:pep:`387`) for details.
98106

99107
The Stable ABI contains symbols exposed in the :ref:`Limited API
100108
<limited-c-api>`, but also other ones – for example, functions necessary to

Doc/howto/logging.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ that; formatting options will also be explained later.
127127

128128
Notice that in this example, we use functions directly on the ``logging``
129129
module, like ``logging.debug``, rather than creating a logger and calling
130-
functions on it. These functions operation on the root logger, but can be useful
130+
functions on it. These functions operate on the root logger, but can be useful
131131
as they will call :func:`~logging.basicConfig` for you if it has not been called yet, like in
132132
this example. In larger programs you'll usually want to control the logging
133133
configuration explicitly however - so for that reason as well as others, it's

Doc/library/errno.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,13 @@ defined by the module. The specific list of defined symbols is available as
613613
No route to host
614614

615615

616+
.. data:: EHWPOISON
617+
618+
Memory page has hardware error.
619+
620+
.. versionadded:: next
621+
622+
616623
.. data:: EALREADY
617624

618625
Operation already in progress. This error is mapped to the

Doc/whatsnew/3.14.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ dis
345345
This feature is also exposed via :option:`dis --show-positions`.
346346
(Contributed by Bénédikt Tran in :gh:`123165`.)
347347

348+
errno
349+
-----
350+
351+
* Add :data:`errno.EHWPOISON` error code.
352+
(Contributed by James Roy in :gh:`126585`.)
348353

349354
fractions
350355
---------

Include/internal/pycore_code.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,12 +609,19 @@ PyAPI_DATA(const struct _PyCode8) _Py_InitCleanup;
609609

610610
#ifdef Py_GIL_DISABLED
611611

612+
static inline _PyCodeArray *
613+
_PyCode_GetTLBCArray(PyCodeObject *co)
614+
{
615+
return _Py_STATIC_CAST(_PyCodeArray *,
616+
_Py_atomic_load_ptr_acquire(&co->co_tlbc));
617+
}
618+
612619
// Return a pointer to the thread-local bytecode for the current thread, if it
613620
// exists.
614621
static inline _Py_CODEUNIT *
615622
_PyCode_GetTLBCFast(PyThreadState *tstate, PyCodeObject *co)
616623
{
617-
_PyCodeArray *code = _Py_atomic_load_ptr_acquire(&co->co_tlbc);
624+
_PyCodeArray *code = _PyCode_GetTLBCArray(co);
618625
int32_t idx = ((_PyThreadStateImpl*) tstate)->tlbc_index;
619626
if (idx < code->size && code->entries[idx] != NULL) {
620627
return (_Py_CODEUNIT *) code->entries[idx];

Include/internal/pycore_frame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ _PyFrame_GetBytecode(_PyInterpreterFrame *f)
9494
{
9595
#ifdef Py_GIL_DISABLED
9696
PyCodeObject *co = _PyFrame_GetCode(f);
97-
_PyCodeArray *tlbc = _Py_atomic_load_ptr_acquire(&co->co_tlbc);
97+
_PyCodeArray *tlbc = _PyCode_GetTLBCArray(co);
9898
assert(f->tlbc_index >= 0 && f->tlbc_index < tlbc->size);
9999
return (_Py_CODEUNIT *)tlbc->entries[f->tlbc_index];
100100
#else

Lib/collections/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
except ImportError:
6060
pass
6161

62+
heapq = None # Lazily imported
63+
6264

6365
################################################################################
6466
### OrderedDict
@@ -633,7 +635,10 @@ def most_common(self, n=None):
633635
return sorted(self.items(), key=_itemgetter(1), reverse=True)
634636

635637
# Lazy import to speedup Python startup time
636-
import heapq
638+
global heapq
639+
if heapq is None:
640+
import heapq
641+
637642
return heapq.nlargest(n, self.items(), key=_itemgetter(1))
638643

639644
def elements(self):

Lib/test/test_socket.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5136,7 +5136,10 @@ def testLargeTimeout(self):
51365136
# gh-126876: Check that a timeout larger than INT_MAX is replaced with
51375137
# INT_MAX in the poll() code path. The following assertion must not
51385138
# fail: assert(INT_MIN <= ms && ms <= INT_MAX).
5139-
large_timeout = _testcapi.INT_MAX + 1
5139+
if _testcapi is not None:
5140+
large_timeout = _testcapi.INT_MAX + 1
5141+
else:
5142+
large_timeout = 2147483648
51405143

51415144
# test recv() with large timeout
51425145
conn, addr = self.serv.accept()
@@ -5151,7 +5154,10 @@ def testLargeTimeout(self):
51515154

51525155
def _testLargeTimeout(self):
51535156
# test sendall() with large timeout
5154-
large_timeout = _testcapi.INT_MAX + 1
5157+
if _testcapi is not None:
5158+
large_timeout = _testcapi.INT_MAX + 1
5159+
else:
5160+
large_timeout = 2147483648
51555161
self.cli.connect((HOST, self.port))
51565162
try:
51575163
self.cli.settimeout(large_timeout)

Makefile.pre.in

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,6 @@ SRCDIRS= @SRCDIRS@
269269
# Other subdirectories
270270
SUBDIRSTOO= Include Lib Misc
271271

272-
# assets for Emscripten browser builds
273-
WASM_ASSETS_DIR=.$(prefix)
274-
WASM_STDLIB=$(WASM_ASSETS_DIR)/lib/python$(VERSION)/os.py
275-
276272
# Files and directories to be distributed
277273
CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
278274
DISTFILES= README.rst ChangeLog $(CONFIGFILES)
@@ -737,6 +733,9 @@ build_all: check-clean-src check-app-store-compliance $(BUILDPYTHON) platform sh
737733
build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \
738734
python-config checksharedmods
739735

736+
.PHONY: build_emscripten
737+
build_emscripten: build_wasm web_example
738+
740739
# Check that the source is clean when building out of source.
741740
.PHONY: check-clean-src
742741
check-clean-src:
@@ -1016,23 +1015,38 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
10161015
else true; \
10171016
fi
10181017

1019-
# wasm32-emscripten browser build
1020-
# wasm assets directory is relative to current build dir, e.g. "./usr/local".
1021-
# --preload-file turns a relative asset path into an absolute path.
1018+
# wasm32-emscripten browser web example
1019+
1020+
WEBEX_DIR=$(srcdir)/Tools/wasm/emscripten/web_example/
1021+
web_example/python.html: $(WEBEX_DIR)/python.html
1022+
@mkdir -p web_example
1023+
@cp $< $@
1024+
1025+
web_example/python.worker.mjs: $(WEBEX_DIR)/python.worker.mjs
1026+
@mkdir -p web_example
1027+
@cp $< $@
10221028

1023-
.PHONY: wasm_stdlib
1024-
wasm_stdlib: $(WASM_STDLIB)
1025-
$(WASM_STDLIB): $(srcdir)/Lib/*.py $(srcdir)/Lib/*/*.py \
1026-
$(srcdir)/Tools/wasm/wasm_assets.py \
1029+
web_example/server.py: $(WEBEX_DIR)/server.py
1030+
@mkdir -p web_example
1031+
@cp $< $@
1032+
1033+
WEB_STDLIB=web_example/python$(VERSION)$(ABI_THREAD).zip
1034+
$(WEB_STDLIB): $(srcdir)/Lib/*.py $(srcdir)/Lib/*/*.py \
1035+
$(WEBEX_DIR)/wasm_assets.py \
10271036
Makefile pybuilddir.txt Modules/Setup.local
1028-
$(PYTHON_FOR_BUILD) $(srcdir)/Tools/wasm/wasm_assets.py \
1029-
--buildroot . --prefix $(prefix)
1037+
$(PYTHON_FOR_BUILD) $(WEBEX_DIR)/wasm_assets.py \
1038+
--buildroot . --prefix $(prefix) -o $@
10301039

1031-
python.html: $(srcdir)/Tools/wasm/python.html python.worker.js
1032-
@cp $(srcdir)/Tools/wasm/python.html $@
1040+
web_example/python.mjs web_example/python.wasm: $(BUILDPYTHON)
1041+
@if test $(HOST_GNU_TYPE) != 'wasm32-unknown-emscripten' ; then \
1042+
echo "Can only build web_example when target is Emscripten" ;\
1043+
exit 1 ;\
1044+
fi
1045+
cp python.mjs web_example/python.mjs
1046+
cp python.wasm web_example/python.wasm
10331047

1034-
python.worker.js: $(srcdir)/Tools/wasm/python.worker.js
1035-
@cp $(srcdir)/Tools/wasm/python.worker.js $@
1048+
.PHONY: web_example
1049+
web_example: web_example/python.mjs web_example/python.worker.mjs web_example/python.html web_example/server.py $(WEB_STDLIB)
10361050

10371051
############################################################################
10381052
# Header files
@@ -3053,8 +3067,7 @@ clean-retain-profile: pycremoval
30533067
find build -name '*.py[co]' -exec rm -f {} ';' || true
30543068
-rm -f pybuilddir.txt
30553069
-rm -f _bootstrap_python
3056-
-rm -f python.html python*.js python.data python*.symbols python*.map
3057-
-rm -f $(WASM_STDLIB)
3070+
-rm -rf web_example python.mjs python.wasm python*.symbols python*.map
30583071
-rm -f Programs/_testembed Programs/_freeze_module
30593072
-rm -rf Python/deepfreeze
30603073
-rm -f Python/frozen_modules/*.h
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Updated the Emscripten web example to use ES6 modules and be built into a
2+
distinct ``web_example`` subfolder.

0 commit comments

Comments
 (0)