8000 Catch up with main · python/cpython@f085a2e · GitHub
[go: up one dir, main page]

Skip to content

Commit f085a2e

Browse files
committed
Catch up with main
2 parents f4cc398 + d8c07f8 commit f085a2e

Some content is hidden

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

55 files changed

+732
-236
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Objects/codeobject.c @markshannon
1818
Objects/frameobject.c @markshannon
1919
Objects/call.c @markshannon
2020
Python/ceval.c @markshannon
21-
Python/compile.c @markshannon
21+
Python/compile.c @markshannon @iritkatriel
2222
Python/ast_opt.c @isidentical
2323
Lib/test/test_patma.py @brandtbucher
2424
Lib/test/test_peepholer.py @brandtbucher
@@ -29,7 +29,6 @@ Lib/test/test_except*.py @iritkatriel
2929
Lib/test/test_traceback.py @iritkatriel
3030
Objects/exceptions.c @iritkatriel
3131
Python/traceback.c @iritkatriel
32-
Python/pythonrun.c @iritkatriel
3332

3433
# Hashing
3534
**/*hashlib* @tiran

Doc/library/errno.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,3 +657,12 @@ defined by the module. The specific list of defined symbols is available as
657657
Interface output queue is full
658658

659659
.. versionadded:: 3.11
660+
661+
.. data:: ENOTCAPABLE
662+
663+
Capabilities insufficient. This error is mapped to the exception
664+
:exc:`PermissionError`.
665+
666+
.. availability:: WASI, FreeBSD
667+
668+
.. versionadded:: 3.11.1

Doc/library/exceptions.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,12 @@ depending on the system error code.
746746

747747
Raised when trying to run an operation without the adequate access
748748
rights - for example filesystem permissions.
749-
Corresponds to :c:data:`errno` :py:data:`~errno.EACCES` and :py:data:`~errno.EPERM`.
749+
Corresponds to :c:data:`errno` :py:data:`~errno.EACCES`,
750+
:py:data:`~errno.EPERM`, and :py:data:`~errno.ENOTCAPABLE`.
751+
752+
.. versionchanged:: 3.11.1
753+
WASI's :py:data:`~errno.ENOTCAPABLE` is now mapped to
754+
:exc:`PermissionError`.
750755

751756
.. exception:: ProcessLookupError
752757

Doc/library/test.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,12 @@ The :mod:`test.support` module defines the following functions:
794794
Decorator for only running the test if :data:`HAVE_DOCSTRINGS`.
795795

796796

797+
.. decorator:: requires_limited_api
798+
799+
Decorator for only running the test if :ref:`Limited C API <stable>`
800+
is available.
801+
802+
797803
.. decorator:: cpython_only
798804

799805
Decorator for tests only applicable to CPython.

Doc/whatsnew/3.11.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Summary -- Release highlights
6464
New syntax features:
6565

6666
* :pep:`654`: Exception Groups and ``except*``.
67-
(Contributed by Irit Katriel in :issue:`45292`.)
6867

6968
New built-in features:
7069

@@ -1644,16 +1643,23 @@ Build Changes
16441643

16451644
* Build dependencies, compiler flags, and linker flags for most stdlib
16461645
extension modules are now detected by :program:`configure`. libffi, libnsl,
1647-
libsqlite3, zlib, bzip2, liblzma, libcrypt, Tcl/Tk libs, and uuid flags
1648-
are detected by ``pkg-config`` (when available).
1646+
libsqlite3, zlib, bzip2, liblzma, libcrypt, Tcl/Tk, and uuid flags
1647+
are detected by ``pkg-config`` (when available). :mod:`tkinter` now
1648+
requires ``pkg-config`` command to detect development settings for Tcl/Tk
1649+
headers and libraries.
16491650
(Contributed by Christian Heimes and Erlend Egeberg Aasland in
16501651
:issue:`45847`, :issue:`45747`, and :issue:`45763`.)
16511652

16521653
.. note::
1653-
Use the environment variables ``TCLTK_CFLAGS`` and ``TCLTK_LIBS`` to
1654-
manually specify the location of Tcl/Tk headers and libraries.
1655-
The :program:`configure` options ``--with-tcltk-includes`` and
1656-
``--with-tcltk-libs`` have been removed.
1654+
Use the environment variables :envvar:`TCLTK_CFLAGS` and
1655+
:envvar:`TCLTK_LIBS` to manually specify the location of Tcl/Tk headers
1656+
and libraries. The :program:`configure` options ``--with-tcltk-includes``
1657+
and ``--with-tcltk-libs`` have been removed.
1658+
1659+
On RHEL 7 and CentOS 7 the development packages do not provide ``tcl.pc``
1660+
and ``tk.pc``, use :envvar:`TCLTK_LIBS="-ltk8.5 -ltkstub8.5 -ltcl8.5"`.
1661+
The directory ``Misc/rhel7`` contains ``.pc`` files and instructions
1662+
how to build Python with RHEL 7's and CentOS 7's Tcl/Tk and OpenSSL.
16571663

16581664
* CPython now has :pep:`11` tier 3 support for cross compiling to WebAssembly
16591665
platform ``wasm32-unknown-emscripten`` (Python in the browser). The effort

Doc/whatsnew/3.12.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ New Features
450450
inherit the ``Py_TPFLAGS_HAVE_VECTORCALL`` flag.
451451
(Contributed by Petr Viktorin in :gh:`93274`.)
452452

453+
The :const:`Py_TPFLAGS_MANAGED_DICT` and :const:`Py_TPFLAGS_MANAGED_WEAKREF`
454+
flags have been added. This allows extensions classes to support object
455+
``__dict__`` and weakrefs with less bookkeeping,
456+
using less memory and with faster access.
457+
453458
Porting to Python 3.12
454459
----------------------
455460

@@ -486,6 +491,18 @@ Porting to Python 3.12
486491
:c:func:`PyUnicode_FromFormatV`.
487492
(Contributed by Philip Georgi in :gh:`95504`.)
488493

494+
* Extension classes wanting to add a ``__dict__`` or weak reference slot
495+
should use :const:`Py_TPFLAGS_MANAGED_DICT` and
496+
:const:`Py_TPFLAGS_MANAGED_WEAKREF` instead of ``tp_dictoffset`` and
497+
``tp_weaklistoffset``, respectively.
498+
The use of ``tp_dictoffset`` and ``tp_weaklistoffset`` is still
499+
supported, but does not fully support multiple inheritance
500+
(:gh: `95589`), and performance may be worse.
501+
Classes declaring :const:`Py_TPFLAGS_MANAGED_DICT` should call
502+
:c:func:`_PyObject_VisitManagedDict` and :c:func:`_PyObject_ClearManagedDict`
503+
to traverse and clear their instance's dictionaries.
504+
To clear weakrefs, call :c:func:`PyObject_ClearWeakRefs`, as before.
505+
489506
Deprecated
490507
----------
491508

Include/internal/pycore_code.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct callable_cache {
118118
PyObject *isinstance;
119119
PyObject *len;
120120
PyObject *list_append;
121+
PyObject *object__getattribute__;
121122
};
122123

123124
/* "Locals plus" for a code object is the set of locals + cell vars +

Include/internal/pycore_object.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static inline size_t
279279
_PyType_PreHeaderSize(PyTypeObject *tp)
280280
{
281281
return _PyType_IS_GC(tp) * sizeof(PyGC_Head) +
282-
_PyType_HasFeature(tp, Py_TPFLAGS_MANAGED_DICT) * 2 * sizeof(PyObject *);
282+
_PyType_HasFeature(tp, Py_TPFLAGS_PREHEADER) * 2 * sizeof(PyObject *);
283283
}
284284

285285
void _PyObject_GC_Link(PyObject *op);
@@ -296,7 +296,7 @@ extern int _Py_CheckSlotResult(
296296

297297
// Test if a type supports weak references
298298
static inline int _PyType_SUPPORTS_WEAKREFS(PyTypeObject *type) {
299-
return (type->tp_weaklistoffset > 0);
299+
return (type->tp_weaklistoffset != 0);
300300
}
301301

302302
extern PyObject* _PyType_AllocNoTrack(PyTypeObject *type, Py_ssize_t nitems);
@@ -346,7 +346,7 @@ _PyDictOrValues_SetValues(PyDictOrValues *ptr, PyDictValues *values)
346346
ptr->values = ((char *)values) - 1;
347347
}
348348

349-
#define MANAGED_DICT_OFFSET (((int)sizeof(PyObject *))*-3)
349+
#define MANAGED_WEAKREF_OFFSET (((Py_ssize_t)sizeof(PyObject *))*-4)
350350

351351
extern PyObject ** _PyObject_ComputedDictPointer(PyObject *);
352352
extern void _PyObject_FreeInstanceAttributes(PyObject *obj);

Include/internal/pycore_opcode.h

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

Include/internal/pycore_runtime.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ extern "C" {
1414
#include "pycore_interp.h" // PyInterpreterState
1515
#include "pycore_unicodeobject.h" // struct _Py_unicode_runtime_ids
1616

17+
struct _getargs_runtime_state {
18+
PyThread_type_lock mutex;
19+
};
1720

1821
/* ceval state */
1922

@@ -114,6 +117,7 @@ typedef struct pyruntimestate {
114117

115118
struct _ceval_runtime_state ceval;
116119
struct _gilstate_runtime_state gilstate;
120+
struct _getargs_runtime_state getargs;
117121

118122
PyPreConfig preconfig;
119123

Include/internal/pycore_typeobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ extern void _PyStaticType_ClearWeakRefs(PyTypeObject *type);
7575
extern void _PyStaticType_Dealloc(PyTypeObject *type);
7676

7777

78+
PyObject *_Py_slot_tp_getattro(PyObject *self, PyObject *name);
79+
PyObject *_Py_slot_tp_getattr_hook(PyObject *self, PyObject *name);
80+
7881
#ifdef __cplusplus
7982
}
8083
#endif

Include/object.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,18 @@ given type object has a specified feature.
360360
/* Track types initialized using _PyStaticType_InitBuiltin(). */
361361
#define _Py_TPFLAGS_STATIC_BUILTIN (1 << 1)
362362

363+
/* Placement of weakref pointers are managed by the VM, not by the type.
364+
* The VM will automatically set tp_weaklistoffset.
365+
*/
366+
#define Py_TPFLAGS_MANAGED_WEAKREF (1 << 3)
367+
363368
/* Placement of dict (and values) pointers are managed by the VM, not by the type.
364-
* The VM will automatically set tp_dictoffset. Should not be used for variable sized
365-
* classes, such as classes that extend tuple.
369+
* The VM will automatically set tp_dictoffset.
366370
*/
367371
#define Py_TPFLAGS_MANAGED_DICT (1 << 4)
368372

373+
#define Py_TPFLAGS_PREHEADER (Py_TPFLAGS_MANAGED_WEAKREF | Py_TPFLAGS_MANAGED_DICT)
374+
369375
/* Set if instances of the type object are treated as sequences for pattern matching */
370376
#define Py_TPFLAGS_SEQUENCE (1 << 5)
371377
/* Set if instances of the type object are treated as mappings for pattern matching */

Include/opcode.h

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

0 commit comments

Comments
 (0)
0