Skip to content

Commit 3fa0326

Browse files
authored
Merge branch 'main' into optimize-off
2 parents fb29089 + 8ab7ad6 commit 3fa0326

File tree

247 files changed

+22836
-31676
lines changed

Some content is hidden

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

247 files changed

+22836
-31676
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ jobs:
518518
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
519519
with:
520520
allowed-failures: >-
521-
build_macos,
522521
build_macos_free_threaded,
523522
build_ubuntu_free_threaded,
524523
build_ubuntu_ssltests,

Doc/bugs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ though it may take a while to be processed.
3838
`Helping with Documentation <https://devguide.python.org/docquality/#helping-with-documentation>`_
3939
Comprehensive guide for individuals that are interested in contributing to Python documentation.
4040

41-
`Documentation Translations <https://devguide.python.org/documenting/#translating>`_
41+
`Documentation Translations <https://devguide.python.org/documentation/translating/>`_
4242
A list of GitHub pages for documentation translation and their primary contacts.
4343

4444

Doc/c-api/unicode.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -992,19 +992,11 @@ These are the UTF-8 codec APIs:
992992
993993
As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
994994
995-
Raise an exception if the *unicode* string contains embedded null
996-
characters. To accept embedded null characters and truncate on purpose
997-
at the first null byte, ``PyUnicode_AsUTF8AndSize(unicode, NULL)`` can be
998-
used instead.
999-
1000995
.. versionadded:: 3.3
1001996
1002997
.. versionchanged:: 3.7
1003998
The return type is now ``const char *`` rather of ``char *``.
1004999
1005-
.. versionchanged:: 3.13
1006-
Raise an exception if the string contains embedded null characters.
1007-
10081000
10091001
UTF-32 Codecs
10101002
"""""""""""""

Doc/data/stable_abi.dat

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/glossary.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,11 @@ Glossary
11381138
an :term:`expression` or one of several constructs with a keyword, such
11391139
as :keyword:`if`, :keyword:`while` or :keyword:`for`.
11401140

1141+
static type checker
1142+
An external tool that reads Python code and analyzes it, looking for
1143+
issues such as incorrect types. See also :term:`type hints <type hint>`
1144+
and the :mod:`typing` module.
1145+
11411146
strong reference
11421147
In Python's C API, a strong reference is a reference to an object
11431148
which is owned by the code holding the reference. The strong
@@ -1214,8 +1219,8 @@ Glossary
12141219
attribute, or a function parameter or return value.
12151220

12161221
Type hints are optional and are not enforced by Python but
1217-
they are useful to static type analysis tools, and aid IDEs with code
1218-
completion and refactoring.
1222+
they are useful to :term:`static type checkers <static type checker>`.
1223+
They can also aid IDEs with code completion and refactoring.
12191224

12201225
Type hints of global variables, class attributes, and functions,
12211226
but not local variables, can be accessed using

Doc/howto/descriptor.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,10 @@ it can be updated:
943943
>>> Movie('Star Wars').director
944944
'J.J. Abrams'
945945

946+
.. testcleanup::
947+
948+
conn.close()
949+
946950

947951
Pure Python Equivalents
948952
^^^^^^^^^^^^^^^^^^^^^^^

Doc/howto/pyporting.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ are:
3939
#. Once your dependencies are no longer blocking you, use continuous integration
4040
to make sure you stay compatible with Python 2 and 3 (tox_ can help test
4141
against multiple versions of Python; ``python -m pip install tox``)
42-
#. Consider using optional static type checking to make sure your type usage
42+
#. Consider using optional :term:`static type checking <static type checker>`
43+
to make sure your type usage
4344
works in both Python 2 and 3 (e.g. use mypy_ to check your typing under both
4445
Python 2 and Python 3; ``python -m pip install mypy``).
4546

@@ -395,7 +396,7 @@ comparisons occur, making the mistake much easier to track down.
395396
Consider using optional static type checking
396397
--------------------------------------------
397398

398-
Another way to help port your code is to use a static type checker like
399+
Another way to help port your code is to use a :term:`static type checker` like
399400
mypy_ or pytype_ on your code. These tools can be used to analyze your code as
400401
if it's being run under Python 2, then you can run the tool a second time as if
401402
your code is running under Python 3. By running a static type checker twice like

Doc/library/datetime.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ on efficient attribute extraction for output formatting and manipulation.
3838
Third-party library with expanded time zone and parsing support.
3939

4040
Package `DateType <https://pypi.org/project/datetype/>`_
41-
Third-party library that introduces distinct static types to e.g. allow static type checkers
41+
Third-party library that introduces distinct static types to e.g. allow
42+
:term:`static type checkers <static type checker>`
4243
to differentiate between naive and aware datetimes.
4344

4445
.. _datetime-naive-aware:

Doc/library/ipaddress.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ write code that handles both IP versions correctly. Address objects are
219219
``True`` if the address is reserved for link-local usage. See
220220
:RFC:`3927`.
221221

222+
.. attribute:: ipv6_mapped
223+
224+
:class:`IPv4Address` object representing the IPv4-mapped IPv6 address. See :RFC:`4291`.
225+
226+
.. versionadded:: 3.13
227+
228+
222229
.. _iana-ipv4-special-registry: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
223230
.. _iana-ipv6-special-registry: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
224231

Doc/library/pdb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ can be overridden by the local file.
580580

581581
Create an alias called *name* that executes *command*. The *command* must
582582
*not* be enclosed in quotes. Replaceable parameters can be indicated by
583-
``%1``, ``%2``, and so on, while ``%*`` is replaced by all the parameters.
583+
``%1``, ``%2``, ... and ``%9``, while ``%*`` is replaced by all the parameters.
584584
If *command* is omitted, the current alias for *name* is shown. If no
585585
arguments are given, all aliases are listed.
586586

Doc/library/symtable.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,21 @@ Examining Symbol Tables
207207

208208
Return the namespace bound to this name. If more than one or no namespace
209209
is bound to this name, a :exc:`ValueError` is raised.
210+
211+
212+
.. _symtable-cli:
213+
214+
Command-Line Usage
215+
------------------
216+
217+
.. versionadded:: 3.13
218+
219+
The :mod:`symtable` module can be executed as a script from the command line.
220+
221+
.. code-block:: sh
222+
223+
python -m symtable [infile...]
224+
225+
Symbol tables are generated for the specified Python source files and
226+
dumped to stdout.
227+
If no input file is specified, the content is read from stdin.

Doc/library/typing.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
.. note::
1919

2020
The Python runtime does not enforce function and variable type annotations.
21-
They can be used by third party tools such as type checkers, IDEs, linters,
22-
etc.
21+
They can be used by third party tools such as :term:`type checkers <static type checker>`,
22+
IDEs, linters, etc.
2323

2424
--------------
2525

@@ -1145,16 +1145,13 @@ These can be used as types in annotations. They all support subscription using
11451145

11461146
from collections.abc import Callable
11471147
from threading import Lock
1148-
from typing import Concatenate, ParamSpec, TypeVar
1149-
1150-
P = ParamSpec('P')
1151-
R = TypeVar('R')
1148+
from typing import Concatenate
11521149

11531150
# Use this lock to ensure that only one thread is executing a function
11541151
# at any time.
11551152
my_lock = Lock()
11561153

1157-
def with_lock(f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]:
1154+
def with_lock[**P, R](f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]:
11581155
'''A type-safe decorator which provides a lock.'''
11591156
def inner(*args: P.args, **kwargs: P.kwargs) -> R:
11601157
# Provide the lock as the first argument.

Doc/reference/datamodel.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,10 +1214,15 @@ Frame objects support one method:
12141214
objects (for example when catching an exception and storing its
12151215
traceback for later use).
12161216

1217-
:exc:`RuntimeError` is raised if the frame is currently executing.
1217+
:exc:`RuntimeError` is raised if the frame is currently executing
1218+
or suspended.
12181219

12191220
.. versionadded:: 3.4
12201221

1222+
.. versionchanged:: 3.13
1223+
Attempting to clear a suspended frame raises :exc:`RuntimeError`
1224+
(as has always been the case for executing frames).
1225+
12211226

12221227
.. _traceback-objects:
12231228

Doc/whatsnew/3.13.rst

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ and only logged in :ref:`Python Development Mode <devmode>` or on :ref:`Python
185185
built on debug mode <debug-build>`.
186186
(Contributed by Victor Stinner in :gh:`62948`.)
187187

188+
ipaddress
189+
---------
190+
191+
* Add the :attr:`ipaddress.IPv4Address.ipv6_mapped` property, which returns the IPv4-mapped IPv6 address.
192+
(Contributed by Charles Machalow in :gh:`109466`.)
193+
188194
opcode
189195
------
190196

@@ -391,6 +397,16 @@ Deprecated
391397
and methods that consider plural forms even if the translation was not found.
392398
(Contributed by Serhiy Storchaka in :gh:`88434`.)
393399

400+
* Calling :meth:`frame.clear` on a suspended frame raises :exc:`RuntimeError`
401+
(as has always been the case for an executing frame).
402+
(Contributed by Irit Katriel in :gh:`79932`.)
403+
404+
* Assignment to a function's ``__code__`` attribute where the new code
405+
object's type does not match the function's type, is deprecated. The
406+
different types are: plain function, generator, async generator and
407+
coroutine.
408+
(Contributed by Irit Katriel in :gh:`81137`.)
409+
394410

395411
Pending Removal in Python 3.14
396412
------------------------------
@@ -970,6 +986,15 @@ Changes in the Python API
970986
The result is now the same if ``wantobjects`` is set to ``0``.
971987
(Contributed by Serhiy Storchaka in :gh:`97928`.)
972988

989+
* Functions :c:func:`PyDict_GetItem`, :c:func:`PyDict_GetItemString`,
990+
:c:func:`PyMapping_HasKey`, :c:func:`PyMapping_HasKeyString`,
991+
:c:func:`PyObject_HasAttr`, :c:func:`PyObject_HasAttrString`, and
992+
:c:func:`PySys_GetObject`, which clear all errors occurred during calling
993+
the function, report now them using :func:`sys.unraisablehook`.
994+
You can consider to replace these functions with other functions as
995+
recomended in the documentation.
996+
(Contributed by Serhiy Storchaka in :gh:`106672`.)
997+
973998

974999
Build Changes
9751000
=============
@@ -1124,9 +1149,6 @@ New Features
11241149
:c:func:`PyErr_WriteUnraisable`, but allow to customize the warning mesage.
11251150
(Contributed by Serhiy Storchaka in :gh:`108082`.)
11261151

1127-
* Add :c:func:`PyUnicode_AsUTF8` function to the limited C API.
1128-
(Contributed by Victor Stinner in :gh:`111089`.)
1129-
11301152

11311153
Porting to Python 3.13
11321154
----------------------
@@ -1197,12 +1219,6 @@ Porting to Python 3.13
11971219
Note that ``Py_TRASHCAN_BEGIN`` has a second argument which
11981220
should be the deallocation function it is in.
11991221

1200-
* The :c:func:`PyUnicode_AsUTF8` function now raises an exception if the string
1201-
contains embedded null characters. To accept embedded null characters and
1202-
truncate on purpose at the first null byte,
1203-
``PyUnicode_AsUTF8AndSize(unicode, NULL)`` can be used instead.
1204-
(Contributed by Victor Stinner in :gh:`111089`.)
1205-
12061222
* On Windows, ``Python.h`` no longer includes the ``<stddef.h>`` standard
12071223
header file. If needed, it should now be included explicitly. For example, it
12081224
provides ``offsetof()`` function, and ``size_t`` and ``ptrdiff_t`` types.

Include/cpython/pthread_stubs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ PyAPI_FUNC(int) pthread_create(pthread_t *restrict thread,
8383
void *(*start_routine)(void *),
8484
void *restrict arg);
8585
PyAPI_FUNC(int) pthread_detach(pthread_t thread);
86+
PyAPI_FUNC(int) pthread_join(pthread_t thread, void** value_ptr);
8687
PyAPI_FUNC(pthread_t) pthread_self(void);
8788
PyAPI_FUNC(int) pthread_exit(void *retval) __attribute__ ((__noreturn__));
8889
PyAPI_FUNC(int) pthread_attr_init(pthread_attr_t *attr);

Include/cpython/unicodeobject.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,22 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData(
440440
const void *buffer,
441441
Py_ssize_t size);
442442

443+
/* --- Manage the default encoding ---------------------------------------- */
444+
445+
/* Returns a pointer to the default encoding (UTF-8) of the
446+
Unicode object unicode.
447+
448+
Like PyUnicode_AsUTF8AndSize(), this also caches the UTF-8 representation
449+
in the unicodeobject.
450+
451+
_PyUnicode_AsString is a #define for PyUnicode_AsUTF8 to
452+
support the previous internal function with the same behaviour.
453+
454+
Use of this API is DEPRECATED since no size information can be
455+
extracted from the returned data.
456+
*/
457+
458+
PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
443459

444460
/* === Characters Type APIs =============================================== */
445461

Include/internal/pycore_ceval.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ PyAPI_FUNC(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyO
2222

2323
extern int _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
2424

25+
extern int _PyEval_SetOpcodeTrace(PyFrameObject *f, bool enable);
26+
2527
// Helper to look up a builtin object
2628
// Export for 'array' shared extension
2729
PyAPI_FUNC(PyObject*) _PyEval_GetBuiltin(PyObject *);

Include/internal/pycore_code.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ extern int _PyStaticCode_Init(PyCodeObject *co);
271271

272272
#ifdef Py_STATS
273273

274+
#include "pycore_bitutils.h" // _Py_bit_length
275+
274276
#define STAT_INC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name++; } while (0)
275277
#define STAT_DEC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name--; } while (0)
276278
#define OPCODE_EXE_INC(opname) do { if (_Py_stats) _Py_stats->opcode_stats[opname].execution_count++; } while (0)

Include/internal/pycore_crossinterp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ extern void _PyXI_Fini(PyInterpreterState *interp);
164164
/* short-term data sharing */
165165
/***************************/
166166

167+
// Ultimately we'd like to preserve enough information about the
168+
// exception and traceback that we could re-constitute (or at least
169+
// simulate, a la traceback.TracebackException), and even chain, a copy
170+
// of the exception in the calling interpreter.
171+
172+
typedef struct _excinfo {
173+
const char *type;
174+
const char *msg;
175+
} _Py_excinfo;
176+
177+
167178
typedef enum error_code {
168179
_PyXI_ERR_NO_ERROR = 0,
169180
_PyXI_ERR_UNCAUGHT_EXCEPTION = -1,

Include/internal/pycore_instruments.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ typedef uint32_t _PyMonitoringEventSet;
6363
PyObject *_PyMonitoring_RegisterCallback(int tool_id, int event_id, PyObject *obj);
6464

6565
int _PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events);
66+
int _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet events);
67+
int _PyMonitoring_GetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet *events);
6668

6769
extern int
6870
_Py_call_instrumentation(PyThreadState *tstate, int event,

Include/internal/pycore_interp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ struct _is {
200200
uint32_t next_func_version;
201201

202202
_Py_GlobalMonitors monitors;
203-
bool f_opcode_trace_set;
204203
bool sys_profile_initialized;
205204
bool sys_trace_initialized;
206205
Py_ssize_t sys_profiling_threads; /* Count of threads with c_profilefunc set */

0 commit comments

Comments
 (0)