Skip to content

Commit cd62fb1

Browse files
authored
Merge branch 'main' into replace_iso_calculation
2 parents a7687be + b51da99 commit cd62fb1

Some content is hidden

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

66 files changed

+1462
-725
lines changed

.github/workflows/require-pr-label.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
label:
9-
name: DO-NOT-MERGE
9+
name: DO-NOT-MERGE / unresolved review
1010
runs-on: ubuntu-latest
1111
timeout-minutes: 10
1212

@@ -15,4 +15,4 @@ jobs:
1515
with:
1616
mode: exactly
1717
count: 0
18-
labels: "DO-NOT-MERGE"
18+
labels: "DO-NOT-MERGE, awaiting changes, awaiting change review"

Doc/library/contextlib.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,15 @@ Functions and classes provided:
304304

305305
This context manager is :ref:`reentrant <reentrant-cms>`.
306306

307+
If the code within the :keyword:`!with` block raises an
308+
:exc:`ExceptionGroup`, suppressed exceptions are removed from the
309+
group. If any exceptions in the group are not suppressed, a group containing them is re-raised.
310+
307311
.. versionadded:: 3.4
308312

313+
.. versionchanged:: 3.12
314+
``suppress`` now supports suppressing exceptions raised as
315+
part of an :exc:`ExceptionGroup`.
309316

310317
.. function:: redirect_stdout(new_target)
311318

Doc/library/dataclasses.rst

Lines changed: 74 additions & 72 deletions
Large diffs are not rendered by default.

Doc/library/dis.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,24 @@ iterations of the loop.
10361036
pushed to the stack before the attribute or unbound method respectively.
10371037

10381038

1039+
.. opcode:: LOAD_SUPER_ATTR (namei)
1040+
1041+
This opcode implements :func:`super` (e.g. ``super().method()`` and
1042+
``super().attr``). It works the same as :opcode:`LOAD_ATTR`, except that
1043+
``namei`` is shifted left by 2 bits instead of 1, and instead of expecting a
1044+
single receiver on the stack, it expects three objects (from top of stack
1045+
down): ``self`` (the first argument to the current method), ``cls`` (the
1046+
class within which the current method was defined), and the global ``super``.
1047+
1048+
The low bit of ``namei`` signals to attempt a method load, as with
1049+
:opcode:`LOAD_ATTR`.
1050+
1051+
The second-low bit of ``namei``, if set, means that this was a two-argument
1052+
call to :func:`super` (unset means zero-argument).
1053+
1054+
.. versionadded:: 3.12
1055+
1056+
10391057
.. opcode:: COMPARE_OP (opname)
10401058

10411059
Performs a Boolean operation. The operation name can be found in

Doc/library/socketserver.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,16 @@ server is the address family.
140140
ForkingUDPServer
141141
ThreadingTCPServer
142142
ThreadingUDPServer
143+
ForkingUnixStreamServer
144+
ForkingUnixDatagramServer
145+
ThreadingUnixStreamServer
146+
ThreadingUnixDatagramServer
143147

144148
These classes are pre-defined using the mix-in classes.
145149

150+
.. versionadded:: 3.12
151+
The ``ForkingUnixStreamServer`` and ``ForkingUnixDatagramServer`` classes
152+
were added.
146153

147154
To implement a service, you must derive a class from :class:`BaseRequestHandler`
148155
and redefine its :meth:`~BaseRequestHandler.handle` method.

Doc/tools/.nitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ Doc/library/csv.rst
111111
Doc/library/ctypes.rst
112112
Doc/library/curses.ascii.rst
113113
Doc/library/curses.rst
114-
Doc/library/dataclasses.rst
115114
Doc/library/datetime.rst
116115
Doc/library/dbm.rst
117116
Doc/library/decimal.rst
@@ -178,7 +177,6 @@ Doc/library/os.rst
178177
Doc/library/ossaudiodev.rst
179178
Doc/library/pickle.rst
180179
Doc/library/pickletools.rst
181-
Doc/library/pkgutil.rst
182180
Doc/library/platform.rst
183181
Doc/library/plistlib.rst
184182
Doc/library/poplib.rst

Include/cpython/initconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
245245
/* --- PyInterpreterConfig ------------------------------------ */
246246

247247
typedef struct {
248+
// XXX "allow_object_sharing"? "own_objects"?
249+
int use_main_obmalloc;
248250
int allow_fork;
249251
int allow_exec;
250252
int allow_threads;
@@ -254,6 +256,7 @@ typedef struct {
254256

255257
#define _PyInterpreterConfig_INIT \
256258
{ \
259+
.use_main_obmalloc = 0, \
257260
.allow_fork = 0, \
258261
.allow_exec = 0, \
259262
.allow_threads = 1, \
@@ -263,6 +266,7 @@ typedef struct {
263266

264267
#define _PyInterpreterConfig_LEGACY_INIT \
265268
{ \
269+
.use_main_obmalloc = 1, \
266270
.allow_fork = 1, \
267271
.allow_exec = 1, \
268272
.allow_threads = 1, \

Include/cpython/pystate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ is available in a given context. For example, forking the process
1111
might not be allowed in the current interpreter (i.e. os.fork() would fail).
1212
*/
1313

14+
/* Set if the interpreter share obmalloc runtime state
15+
with the main interpreter. */
16+
#define Py_RTFLAGS_USE_MAIN_OBMALLOC (1UL << 5)
17+
1418
/* Set if import should check a module for subinterpreter support. */
1519
#define Py_RTFLAGS_MULTI_INTERP_EXTENSIONS (1UL << 8)
1620

Include/internal/pycore_interp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ extern "C" {
2323
#include "pycore_function.h" // FUNC_MAX_WATCHERS
2424
#include "pycore_genobject.h" // struct _Py_async_gen_state
2525
#include "pycore_gc.h" // struct _gc_runtime_state
26+
#include "pycore_global_objects.h" // struct _Py_interp_static_objects
2627
#include "pycore_import.h" // struct _import_state
2728
#include "pycore_instruments.h" // PY_MONITORING_EVENTS
2829
#include "pycore_list.h" // struct _Py_list_state
29-
#include "pycore_global_objects.h" // struct _Py_interp_static_objects
3030
#include "pycore_object_state.h" // struct _py_object_state
31+
#include "pycore_obmalloc.h" // struct obmalloc_state
3132
#include "pycore_tuple.h" // struct _Py_tuple_state
3233
#include "pycore_typeobject.h" // struct type_cache
3334
#include "pycore_unicodeobject.h" // struct _Py_unicode_state
@@ -82,6 +83,8 @@ struct _is {
8283
int _initialized;
8384
int finalizing;
8485

86+
struct _obmalloc_state obmalloc;
87+
8588
struct _ceval_state ceval;
8689
struct _gc_runtime_state gc;
8790

Include/internal/pycore_obmalloc.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,12 @@ struct _obmalloc_usage {
657657
#endif /* WITH_PYMALLOC_RADIX_TREE */
658658

659659

660-
struct _obmalloc_state {
660+
struct _obmalloc_global_state {
661661
int dump_debug_stats;
662+
Py_ssize_t interpreter_leaks;
663+
};
664+
665+
struct _obmalloc_state {
662666
struct _obmalloc_pools pools;
663667
struct _obmalloc_mgmt mgmt;
664668
struct _obmalloc_usage usage;
@@ -675,7 +679,11 @@ void _PyObject_VirtualFree(void *, size_t size);
675679

676680

677681
/* This function returns the number of allocated memory blocks, regardless of size */
678-
PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
682+
extern Py_ssize_t _Py_GetGlobalAllocatedBlocks(void);
683+
#define _Py_GetAllocatedBlocks() \
684+
_Py_GetGlobalAllocatedBlocks()
685+
extern Py_ssize_t _PyInterpreterState_GetAllocatedBlocks(PyInterpreterState *);
686+
extern void _PyInterpreterState_FinalizeAllocatedBlocks(PyInterpreterState *);
679687

680688

681689
#ifdef WITH_PYMALLOC

Include/internal/pycore_obmalloc_init.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ extern "C" {
5454
# error "NB_SMALL_SIZE_CLASSES should be less than 64"
5555
#endif
5656

57-
#define _obmalloc_state_INIT(obmalloc) \
57+
#define _obmalloc_global_state_INIT \
5858
{ \
5959
.dump_debug_stats = -1, \
60+
}
61+
62+
#define _obmalloc_state_INIT(obmalloc) \
63+
{ \
6064
.pools = { \
6165
.used = _obmalloc_pools_INIT(obmalloc.pools), \
6266
}, \

Include/internal/pycore_opcode.h

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_pylifecycle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extern void _PyAtExit_Fini(PyInterpreterState *interp);
6464
extern void _PyThread_FiniType(PyInterpreterState *interp);
6565
extern void _Py_Deepfreeze_Fini(void);
6666
extern void _PyArg_Fini(void);
67+
extern void _Py_FinalizeAllocatedBlocks(_PyRuntimeState *);
6768

6869
extern PyStatus _PyGILState_Init(PyInterpreterState *interp);
6970
extern PyStatus _PyGILState_SetTstate(PyThreadState *tstate);

Include/internal/pycore_pystate.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ _Py_IsMainInterpreter(PyInterpreterState *interp)
3333
return (interp == _PyInterpreterState_Main());
3434
}
3535

36+
static inline int
37+
_Py_IsMainInterpreterFinalizing(PyInterpreterState *interp)
38+
{
39+
return (_PyRuntimeState_GetFinalizing(interp->runtime) != NULL &&
40+
interp == &interp->runtime->_main_interpreter);
41+
}
42+
3643

3744
static inline const PyConfig *
3845
_Py_GetMainConfig(void)

Include/internal/pycore_runtime.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ extern "C" {
2121
#include "pycore_pymem.h" // struct _pymem_allocators
2222
#include "pycore_pyhash.h" // struct pyhash_runtime_state
2323
#include "pycore_pythread.h" // struct _pythread_runtime_state
24-
#include "pycore_obmalloc.h" // struct obmalloc_state
2524
#include "pycore_signal.h" // struct _signals_runtime_state
2625
#include "pycore_time.h" // struct _time_runtime_state
2726
#include "pycore_tracemalloc.h" // struct _tracemalloc_runtime_state
27+
#include "pycore_typeobject.h" // struct types_runtime_state
2828
#include "pycore_unicodeobject.h" // struct _Py_unicode_runtime_ids
2929

3030
struct _getargs_runtime_state {
@@ -87,7 +87,7 @@ typedef struct pyruntimestate {
8787
_Py_atomic_address _finalizing;
8888

8989
struct _pymem_allocators allocators;
90-
struct _obmalloc_state obmalloc;
90+
struct _obmalloc_global_state obmalloc;
9191
struct pyhash_runtime_state pyhash_state;
9292
struct _time_runtime_state time;
9393
struct _pythread_runtime_state threads;
@@ -150,13 +150,7 @@ typedef struct pyruntimestate {
150150
struct _py_object_runtime_state object_state;
151151
struct _Py_float_runtime_state float_state;
152152
struct _Py_unicode_runtime_state unicode_state;
153-
154-
struct {
155-
/* Used to set PyTypeObject.tp_version_tag */
156-
// bpo-42745: next_version_tag remains shared by all interpreters
157-
// because of static types.
158-
unsigned int next_version_tag;
159-
} types;
153+
struct _types_runtime_state types;
160154

161155
/* All the objects that are shared by the runtime's interpreters. */
162156
struct _Py_static_objects static_objects;

Include/internal/pycore_runtime_init.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern PyTypeObject _PyExc_MemoryError;
2929
_pymem_allocators_debug_INIT, \
3030
_pymem_allocators_obj_arena_INIT, \
3131
}, \
32-
.obmalloc = _obmalloc_state_INIT(runtime.obmalloc), \
32+
.obmalloc = _obmalloc_global_state_INIT, \
3333
.pyhash_state = pyhash_state_INIT, \
3434
.signals = _signals_RUNTIME_INIT, \
3535
.interpreters = { \
@@ -93,6 +93,7 @@ extern PyTypeObject _PyExc_MemoryError;
9393
{ \
9494
.id_refcount = -1, \
9595
.imports = IMPORTS_INIT, \
96+
.obmalloc = _obmalloc_state_INIT(INTERP.obmalloc), \
9697
.ceval = { \
9798
.recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
9899
}, \
@@ -112,6 +113,9 @@ extern PyTypeObject _PyExc_MemoryError;
112113
.func_state = { \
113114
.next_version = 1, \
114115
}, \
116+
.types = { \
117+
.next_version_tag = _Py_TYPE_BASE_VERSION_TAG, \
118+
}, \
115119
.static_objects = { \
116120
.singletons = { \
117121
._not_used = 1, \

0 commit comments

Comments
 (0)