Skip to content

Commit ee96259

Browse files
committed
Merge branch 'main' into pythongh-114271-remove-tstate_lock
2 parents 3121623 + ebf29b3 commit ee96259

File tree

300 files changed

+5902
-3666
lines changed

Some content is hidden

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

300 files changed

+5902
-3666
lines changed

.devcontainer/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ FROM docker.io/library/fedora:37
22

33
ENV CC=clang
44

5-
ENV WASI_SDK_VERSION=20
5+
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.2
9+
ENV WASMTIME_VERSION=18.0.3
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/workflows/build.yml

+4
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ jobs:
206206
uses: ./.github/workflows/reusable-macos.yml
207207
with:
208208
config_hash: ${{ needs.check_source.outputs.config_hash }}
209+
# macos-14 is M1, macos-13 is Intel
210+
os-matrix: '["macos-14", "macos-13"]'
209211

210212
build_macos_free_threading:
211213
name: 'macOS (free-threading)'
@@ -215,6 +217,8 @@ jobs:
215217
with:
216218
config_hash: ${{ needs.check_source.outputs.config_hash }}
217219
free-threading: true
220+
# macos-14 is M1
221+
os-matrix: '["macos-14"]'
218222

219223
build_ubuntu:
220224
name: 'Ubuntu'

.github/workflows/reusable-macos.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
required: false
99
type: boolean
1010
default: false
11+
os-matrix:
12+
required: false
13+
type: string
1114

1215
jobs:
1316
build_macos:
@@ -22,10 +25,7 @@ jobs:
2225
strategy:
2326
fail-fast: false
2427
matrix:
25-
os: [
26-
"macos-14", # M1
27-
"macos-13", # Intel
28-
]
28+
os: ${{fromJson(inputs.os-matrix)}}
2929
runs-on: ${{ matrix.os }}
3030
steps:
3131
- uses: actions/checkout@v4

.github/workflows/reusable-wasi.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
timeout-minutes: 60
1212
runs-on: ubuntu-20.04
1313
env:
14-
WASMTIME_VERSION: 18.0.2
15-
WASI_SDK_VERSION: 20
14+
WASMTIME_VERSION: 18.0.3
15+
WASI_SDK_VERSION: 21
1616
WASI_SDK_PATH: /opt/wasi-sdk
1717
CROSS_BUILD_PYTHON: cross-build/build
1818
CROSS_BUILD_WASI: cross-build/wasm32-wasi

.github/workflows/stale.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Mark stale pull requests
22

33
on:
44
schedule:
5-
- cron: "0 0 * * *"
5+
- cron: "0 */12 * * *"
66

77
permissions:
88
pull-requests: write

Doc/c-api/long.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
450450
a “fast path” for small integers. For compact values use
451451
:c:func:`PyUnstable_Long_CompactValue`; for others fall back to a
452452
:c:func:`PyLong_As* <PyLong_AsSize_t>` function or
453-
:c:func:`calling <PyObject_CallMethod>` :meth:`int.to_bytes`.
453+
:c:func:`PyLong_AsNativeBytes`.
454454
455455
The speedup is expected to be negligible for most users.
456456

Doc/c-api/type.rst

+15
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,21 @@ Type Objects
185185
186186
.. versionadded:: 3.11
187187
188+
.. c:function:: PyObject* PyType_GetFullyQualifiedName(PyTypeObject *type)
189+
190+
Return the type's fully qualified name. Equivalent to
191+
``f"{type.__module__}.{type.__qualname__}"``, or ``type.__qualname__`` if
192+
``type.__module__`` is not a string or is equal to ``"builtins"``.
193+
194+
.. versionadded:: 3.13
195+
196+
.. c:function:: PyObject* PyType_GetModuleName(PyTypeObject *type)
197+
198+
Return the type's module name. Equivalent to getting the ``type.__module__``
199+
attribute.
200+
201+
.. versionadded:: 3.13
202+
188203
.. c:function:: void* PyType_GetSlot(PyTypeObject *type, int slot)
189204
190205
Return the function pointer stored in the given slot. If the

Doc/c-api/unicode.rst

+23
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,26 @@ APIs:
518518
- :c:expr:`PyObject*`
519519
- The result of calling :c:func:`PyObject_Repr`.
520520
521+
* - ``T``
522+
- :c:expr:`PyObject*`
523+
- Get the fully qualified name of an object type;
524+
call :c:func:`PyType_GetFullyQualifiedName`.
525+
526+
* - ``T#``
527+
- :c:expr:`PyObject*`
528+
- Similar to ``T`` format, but use a colon (``:``) as separator between
529+
the module name and the qualified name.
530+
531+
* - ``N``
532+
- :c:expr:`PyTypeObject*`
533+
- Get the fully qualified name of a type;
534+
call :c:func:`PyType_GetFullyQualifiedName`.
535+
536+
* - ``N#``
537+
- :c:expr:`PyTypeObject*`
538+
- Similar to ``N`` format, but use a colon (``:``) as separator between
539+
the module name and the qualified name.
540+
521541
.. note::
522542
The width formatter unit is number of characters rather than bytes.
523543
The precision formatter unit is number of bytes or :c:type:`wchar_t`
@@ -553,6 +573,9 @@ APIs:
553573
In previous versions it caused all the rest of the format string to be
554574
copied as-is to the result string, and any extra arguments discarded.
555575
576+
.. versionchanged:: 3.13
577+
Support for ``%T``, ``%T#``, ``%N`` and ``%N#`` formats added.
578+
556579
557580
.. c:function:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)
558581

Doc/data/stable_abi.dat

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/faq/design.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,11 @@ is evaluated in all cases.
259259
Why isn't there a switch or case statement in Python?
260260
-----------------------------------------------------
261261

262-
You can do this easily enough with a sequence of ``if... elif... elif... else``.
263-
For literal values, or constants within a namespace, you can also use a
264-
``match ... case`` statement.
262+
In general, structured switch statements execute one block of code
263+
when an expression has a particular value or set of values.
264+
Since Python 3.10 one can easily match literal values, or constants
265+
within a namespace, with a ``match ... case`` statement.
266+
An older alternative is a sequence of ``if... elif... elif... else``.
265267

266268
For cases where you need to choose from a very large number of possibilities,
267269
you can create a dictionary mapping case values to functions to call. For
@@ -290,6 +292,9 @@ It's suggested that you use a prefix for the method names, such as ``visit_`` in
290292
this example. Without such a prefix, if values are coming from an untrusted
291293
source, an attacker would be able to call any method on your object.
292294

295+
Imitating switch with fallthrough, as with C's switch-case-default,
296+
is possible, much harder, and less needed.
297+
293298

294299
Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation?
295300
--------------------------------------------------------------------------------------------------------

Doc/faq/extending.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ to learn Python's C API.
5050
If you need to interface to some C or C++ library for which no Python extension
5151
currently exists, you can try wrapping the library's data types and functions
5252
with a tool such as `SWIG <https://www.swig.org>`_. `SIP
53-
<https://riverbankcomputing.com/software/sip/intro>`__, `CXX
53+
<https://github.com/Python-SIP/sip>`__, `CXX
5454
<https://cxx.sourceforge.net/>`_ `Boost
5555
<https://www.boost.org/libs/python/doc/index.html>`_, or `Weave
5656
<https://github.com/scipy/weave>`_ are also

Doc/glossary.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,11 @@ Glossary
841841
Some named tuples are built-in types (such as the above examples).
842842
Alternatively, a named tuple can be created from a regular class
843843
definition that inherits from :class:`tuple` and that defines named
844-
fields. Such a class can be written by hand or it can be created with
845-
the factory function :func:`collections.namedtuple`. The latter
846-
technique also adds some extra methods that may not be found in
847-
hand-written or built-in named tuples.
844+
fields. Such a class can be written by hand, or it can be created by
845+
inheriting :class:`typing.NamedTuple`, or with the factory function
846+
:func:`collections.namedtuple`. The latter techniques also add some
847+
extra methods that may not be found in hand-written or built-in named
848+
tuples.
848849

849850
namespace
850851
The place where a variable is stored. Namespaces are implemented as

Doc/howto/logging-cookbook.rst

+36-13
Original file line numberDiff line numberDiff line change
@@ -3418,9 +3418,10 @@ The worker thread is implemented using Qt's ``QThread`` class rather than the
34183418
:mod:`threading` module, as there are circumstances where one has to use
34193419
``QThread``, which offers better integration with other ``Qt`` components.
34203420

3421-
The code should work with recent releases of either ``PySide2`` or ``PyQt5``.
3422-
You should be able to adapt the approach to earlier versions of Qt. Please
3423-
refer to the comments in the code snippet for more detailed information.
3421+
The code should work with recent releases of either ``PySide6``, ``PyQt6``,
3422+
``PySide2`` or ``PyQt5``. You should be able to adapt the approach to earlier
3423+
versions of Qt. Please refer to the comments in the code snippet for more
3424+
detailed information.
34243425

34253426
.. code-block:: python3
34263427
@@ -3430,16 +3431,25 @@ refer to the comments in the code snippet for more detailed information.
34303431
import sys
34313432
import time
34323433
3433-
# Deal with minor differences between PySide2 and PyQt5
3434+
# Deal with minor differences between different Qt packages
34343435
try:
3435-
from PySide2 import QtCore, QtGui, QtWidgets
3436+
from PySide6 import QtCore, QtGui, QtWidgets
34363437
Signal = QtCore.Signal
34373438
Slot = QtCore.Slot
34383439
except ImportError:
3439-
from PyQt5 import QtCore, QtGui, QtWidgets
3440-
Signal = QtCore.pyqtSignal
3441-
Slot = QtCore.pyqtSlot
3442-
3440+
try:
3441+
from PyQt6 import QtCore, QtGui, QtWidgets
3442+
Signal = QtCore.pyqtSignal
3443+
Slot = QtCore.pyqtSlot
3444+
except ImportError:
3445+
try:
3446+
from PySide2 import QtCore, QtGui, QtWidgets
3447+
Signal = QtCore.Signal
3448+
Slot = QtCore.Slot
3449+
except ImportError:
3450+
from PyQt5 import QtCore, QtGui, QtWidgets
3451+
Signal = QtCore.pyqtSignal
3452+
Slot = QtCore.pyqtSlot
34433453
34443454
logger = logging.getLogger(__name__)
34453455
@@ -3511,8 +3521,14 @@ refer to the comments in the code snippet for more detailed information.
35113521
while not QtCore.QThread.currentThread().isInterruptionRequested():
35123522
delay = 0.5 + random.random() * 2
35133523
time.sleep(delay)
3514-
level = random.choice(LEVELS)
3515-
logger.log(level, 'Message after delay of %3.1f: %d', delay, i, extra=extra)
3524+
try:
3525+
if random.random() < 0.1:
3526+
raise ValueError('Exception raised: %d' % i)
3527+
else:
3528+
level = random.choice(LEVELS)
3529+
logger.log(level, 'Message after delay of %3.1f: %d', delay, i, extra=extra)
3530+
except ValueError as e:
3531+
logger.exception('Failed: %s', e, extra=extra)
35163532
i += 1
35173533
35183534
#
@@ -3539,7 +3555,10 @@ refer to the comments in the code snippet for more detailed information.
35393555
self.textedit = te = QtWidgets.QPlainTextEdit(self)
35403556
# Set whatever the default monospace font is for the platform
35413557
f = QtGui.QFont('nosuchfont')
3542-
f.setStyleHint(f.Monospace)
3558+
if hasattr(f, 'Monospace'):
3559+
f.setStyleHint(f.Monospace)
3560+
else:
3561+
f.setStyleHint(f.StyleHint.Monospace) # for Qt6
35433562
te.setFont(f)
35443563
te.setReadOnly(True)
35453564
PB = QtWidgets.QPushButton
@@ -3626,7 +3645,11 @@ refer to the comments in the code snippet for more detailed information.
36263645
app = QtWidgets.QApplication(sys.argv)
36273646
example = Window(app)
36283647
example.show()
3629-
sys.exit(app.exec_())
3648+
if hasattr(app, 'exec'):
3649+
rc = app.exec()
3650+
else:
3651+
rc = app.exec_()
3652+
sys.exit(rc)
36303653
36313654
if __name__=='__main__':
36323655
main()

0 commit comments

Comments
 (0)