Skip to content

Commit 0b01f51

Browse files
authored
Merge branch 'main' into 132413-take2
2 parents 7f31245 + 732d1b0 commit 0b01f51

File tree

92 files changed

+2637
-981
lines changed

Some content is hidden

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

92 files changed

+2637
-981
lines changed

.github/workflows/mypy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ on:
88
pull_request:
99
paths:
1010
- ".github/workflows/mypy.yml"
11+
- "Lib/_colorize.py"
1112
- "Lib/_pyrepl/**"
1213
- "Lib/test/libregrtest/**"
14+
- "Misc/mypy/**"
1315
- "Tools/build/generate_sbom.py"
1416
- "Tools/cases_generator/**"
1517
- "Tools/clinic/**"

Doc/c-api/init.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,16 +1517,6 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
15171517
.. versionadded:: 3.8
15181518
15191519
1520-
.. c:function:: PyObject* PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *interp)
1521-
1522-
Return a :term:`strong reference` to the ``__main__`` :ref:`module object <moduleobjects>`
1523-
for the given interpreter.
1524-
1525-
The caller must have an :term:`attached thread state`.
1526-
1527-
.. versionadded:: 3.13
1528-
1529-
15301520
.. c:type:: PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
15311521
15321522
Type of a frame evaluation function.

Doc/c-api/unicode.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ Python:
3333

3434
.. c:var:: PyTypeObject PyUnicode_Type
3535
36-
This instance of :c:type:`PyTypeObject` represents the Python Unicode type. It
37-
is exposed to Python code as :py:class:`str`.
36+
This instance of :c:type:`PyTypeObject` represents the Python Unicode type.
37+
It is exposed to Python code as :py:class:`str`.
38+
39+
40+
.. c:var:: PyTypeObject PyUnicodeIter_Type
41+
42+
This instance of :c:type:`PyTypeObject` represents the Python Unicode
43+
iterator type. It is used to iterate over Unicode string objects.
3844

3945

4046
.. c:type:: Py_UCS4

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ although there is currently no date scheduled for their removal.
1313
deprecated.
1414
* The :class:`argparse.FileType` type converter is deprecated.
1515

16-
* :mod:`array`'s ``'u'`` format code (:gh:`57281`)
17-
1816
* :mod:`builtins`:
1917

2018
* ``bool(NotImplemented)``.

Doc/library/pdb.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,21 @@ slightly different way:
188188
.. versionadded:: 3.14
189189
The *commands* argument.
190190

191+
192+
.. awaitablefunction:: set_trace_async(*, header=None, commands=None)
193+
194+
async version of :func:`set_trace`. This function should be used inside an
195+
async function with :keyword:`await`.
196+
197+
.. code-block:: python
198+
199+
async def f():
200+
await pdb.set_trace_async()
201+
202+
:keyword:`await` statements are supported if the debugger is invoked by this function.
203+
204+
.. versionadded:: 3.14
205+
191206
.. function:: post_mortem(t=None)
192207

193208
Enter post-mortem debugging of the given exception or

Doc/whatsnew/3.14.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,11 @@ pdb
11681168
backend by default, which is configurable.
11691169
(Contributed by Tian Gao in :gh:`124533`.)
11701170

1171+
* :func:`pdb.set_trace_async` is added to support debugging asyncio
1172+
coroutines. :keyword:`await` statements are supported with this
1173+
function.
1174+
(Contributed by Tian Gao in :gh:`132576`.)
1175+
11711176

11721177
pickle
11731178
------
@@ -1637,6 +1642,13 @@ Deprecated
16371642
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
16381643
(Contributed by Bénédikt Tran in :gh:`119698`.)
16391644

1645+
* :mod:`tkinter`:
1646+
The :class:`!tkinter.Variable` methods :meth:`!trace_variable`,
1647+
:meth:`!trace_vdelete` and :meth:`!trace_vinfo` are now deprecated.
1648+
Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!trace_info`
1649+
instead.
1650+
(Contributed by Serhiy Storchaka in :gh:`120220`.)
1651+
16401652
* :mod:`urllib.parse`:
16411653
Accepting objects with false values (like ``0`` and ``[]``) except empty
16421654
strings, byte-like objects and ``None`` in :mod:`urllib.parse` functions
@@ -2280,3 +2292,10 @@ Removed
22802292
* Remove the private ``_Py_InitializeMain()`` function. It was a
22812293
:term:`provisional API` added to Python 3.8 by :pep:`587`.
22822294
(Contributed by Victor Stinner in :gh:`129033`.)
2295+
2296+
* The undocumented APIs :c:macro:`!Py_C_RECURSION_LIMIT` and
2297+
:c:member:`!PyThreadState.c_recursion_remaining`, added in 3.13, are removed
2298+
without a deprecation period.
2299+
Please use :c:func:`Py_EnterRecursiveCall` to guard against runaway recursion
2300+
in C code.
2301+
(Removed in :gh:`133079`, see also :gh:`130396`.)

Include/cpython/pystate.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
99
PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int);
1010

11-
PyAPI_FUNC(PyObject *) PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *);
12-
1311
/* State unique per thread */
1412

1513
/* Py_tracefunc return -1 when raising an exception, or 0 for success. */
@@ -120,8 +118,6 @@ struct _ts {
120118

121119
int py_recursion_remaining;
122120
int py_recursion_limit;
123-
124-
int c_recursion_remaining; /* Retained for backwards compatibility. Do not use */
125121
int recursion_headroom; /* Allow 50 more calls to handle any errors. */
126122

127123
/* 'tracing' keeps track of the execution depth when tracing/profiling.
@@ -212,8 +208,6 @@ struct _ts {
212208
_PyRemoteDebuggerSupport remote_debugger_support;
213209
};
214210

215-
# define Py_C_RECURSION_LIMIT 5000
216-
217211
/* other API */
218212

219213
/* Similar to PyThreadState_Get(), but don't issue a fatal error

Include/internal/pycore_code.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ typedef struct {
177177
*/
178178

179179
// Note that these all fit within a byte, as do combinations.
180-
// Later, we will use the smaller numbers to differentiate the different
181-
// kinds of locals (e.g. pos-only arg, varkwargs, local-only).
182-
#define CO_FAST_HIDDEN 0x10
183-
#define CO_FAST_LOCAL 0x20
184-
#define CO_FAST_CELL 0x40
185-
#define CO_FAST_FREE 0x80
180+
#define CO_FAST_ARG_POS (0x02) // pos-only, pos-or-kw, varargs
181+
#define CO_FAST_ARG_KW (0x04) // kw-only, pos-or-kw, varkwargs
182+
#define CO_FAST_ARG_VAR (0x08) // varargs, varkwargs
183+
#define CO_FAST_ARG (CO_FAST_ARG_POS | CO_FAST_ARG_KW | CO_FAST_ARG_VAR)
184+
#define CO_FAST_HIDDEN (0x10)
185+
#define CO_FAST_LOCAL (0x20)
186+
#define CO_FAST_CELL (0x40)
187+
#define CO_FAST_FREE (0x80)
186188

187189
typedef unsigned char _PyLocals_Kind;
188190

@@ -315,6 +317,7 @@ extern void _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int op
315317
extern void _Py_Specialize_Send(_PyStackRef receiver, _Py_CODEUNIT *instr);
316318
extern void _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
317319
extern void _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);
320+
extern void _Py_GatherStats_GetIter(_PyStackRef iterable);
318321

319322
// Utility functions for reading/writing 32/64-bit values in the inline caches.
320323
// Great care should be taken to ensure that these functions remain correct and
@@ -561,6 +564,10 @@ extern void _Py_ClearTLBCIndex(_PyThreadStateImpl *tstate);
561564
extern int _Py_ClearUnusedTLBC(PyInterpreterState *interp);
562565
#endif
563566

567+
568+
PyAPI_FUNC(int) _PyCode_ReturnsOnlyNone(PyCodeObject *);
569+
570+
564571
#ifdef __cplusplus
565572
}
566573
#endif

Include/internal/pycore_crossinterp.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ PyAPI_FUNC(void) _PyXIData_Clear(PyInterpreterState *, _PyXIData_t *);
112112
do { \
113113
(DATA)->free = (FUNC); \
114114
} while (0)
115+
#define _PyXIData_CHECK_FREE(DATA, FUNC) \
116+
((DATA)->free == (FUNC))
115117
// Additionally, some shareable types are essentially light wrappers
116118
// around other shareable types. The xidatafunc of the wrapper
117119
// can often be implemented by calling the wrapped object's
@@ -123,6 +125,8 @@ PyAPI_FUNC(void) _PyXIData_Clear(PyInterpreterState *, _PyXIData_t *);
123125
do { \
124126
(DATA)->new_object = (FUNC); \
125127
} while (0)
128+
#define _PyXIData_CHECK_NEW_OBJECT(DATA, FUNC) \
129+
((DATA)->new_object == (FUNC))
126130

127131

128132
/* getting cross-interpreter data */
@@ -148,6 +152,32 @@ PyAPI_FUNC(int) _PyObject_GetXIData(
148152
PyObject *,
149153
_PyXIData_t *);
150154

155+
// _PyObject_GetXIData() for bytes
156+
typedef struct {
157+
const char *bytes;
158+
Py_ssize_t len;
159+
} _PyBytes_data_t;
160+
PyAPI_FUNC(int) _PyBytes_GetData(PyObject *, _PyBytes_data_t *);
161+
PyAPI_FUNC(PyObject *) _PyBytes_FromData(_PyBytes_data_t *);
162+
PyAPI_FUNC(PyObject *) _PyBytes_FromXIData(_PyXIData_t *);
163+
PyAPI_FUNC(int) _PyBytes_GetXIData(
164+
PyThreadState *,
165+
PyObject *,
166+
_PyXIData_t *);
167+
PyAPI_FUNC(_PyBytes_data_t *) _PyBytes_GetXIDataWrapped(
168+
PyThreadState *,
169+
PyObject *,
170+
size_t,
171+
xid_newobjfunc,
172+
_PyXIData_t *);
173+
174+
// _PyObject_GetXIData() for marshal
175+
PyAPI_FUNC(PyObject *) _PyMarshal_ReadObjectFromXIData(_PyXIData_t *);
176+
PyAPI_FUNC(int) _PyMarshal_GetXIData(
177+
PyThreadState *,
178+
PyObject *,
179+
_PyXIData_t *);
180+
151181

152182
/* using cross-interpreter data */
153183

Include/internal/pycore_import.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern void _PyImport_SetDLOpenFlags(PyInterpreterState *interp, int new_val);
6363

6464
extern PyObject * _PyImport_InitModules(PyInterpreterState *interp);
6565
extern PyObject * _PyImport_GetModules(PyInterpreterState *interp);
66+
extern PyObject * _PyImport_GetModulesRef(PyInterpreterState *interp);
6667
extern void _PyImport_ClearModules(PyInterpreterState *interp);
6768

6869
extern void _PyImport_ClearModulesByIndex(PyInterpreterState *interp);

0 commit comments

Comments
 (0)