Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into tools/refcounts/lin…
Browse files Browse the repository at this point in the history
…t-127443
  • Loading branch information
picnixz committed Dec 2, 2024
2 parents a3becf0 + bf21e21 commit 3ac1ff1
Show file tree
Hide file tree
Showing 65 changed files with 953 additions and 487 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/jit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
- name: Native macOS
if: runner.os == 'macOS'
Expand Down
2 changes: 1 addition & 1 deletion Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pydoc-topics: build

.PHONY: gettext
gettext: BUILDER = gettext
gettext: SPHINXOPTS += -d build/doctrees-gettext
gettext: override SPHINXOPTS := -d build/doctrees-gettext $(SPHINXOPTS)
gettext: build

.PHONY: htmlview
Expand Down
48 changes: 23 additions & 25 deletions Doc/c-api/type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -529,19 +529,19 @@ The following functions and structs are used to create
The following “offset” fields cannot be set using :c:type:`PyType_Slot`:
* :c:member:`~PyTypeObject.tp_weaklistoffset`
(use :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)
* :c:member:`~PyTypeObject.tp_dictoffset`
(use :c:macro:`Py_TPFLAGS_MANAGED_DICT` instead if possible)
* :c:member:`~PyTypeObject.tp_vectorcall_offset`
(use ``"__vectorcalloffset__"`` in
:ref:`PyMemberDef <pymemberdef-offsets>`)
If it is not possible to switch to a ``MANAGED`` flag (for example,
for vectorcall or to support Python older than 3.12), specify the
offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
for details.
* :c:member:`~PyTypeObject.tp_weaklistoffset`
(use :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)
* :c:member:`~PyTypeObject.tp_dictoffset`
(use :c:macro:`Py_TPFLAGS_MANAGED_DICT` instead if possible)
* :c:member:`~PyTypeObject.tp_vectorcall_offset`
(use ``"__vectorcalloffset__"`` in
:ref:`PyMemberDef <pymemberdef-offsets>`)
If it is not possible to switch to a ``MANAGED`` flag (for example,
for vectorcall or to support Python older than 3.12), specify the
offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
for details.
The following internal fields cannot be set at all when creating a heap
type:
Expand All @@ -557,20 +557,18 @@ The following functions and structs are used to create
To avoid issues, use the *bases* argument of
:c:func:`PyType_FromSpecWithBases` instead.
.. versionchanged:: 3.9
Slots in :c:type:`PyBufferProcs` may be set in the unlimited API.
.. versionchanged:: 3.9
Slots in :c:type:`PyBufferProcs` may be set in the unlimited API.
.. versionchanged:: 3.11
:c:member:`~PyBufferProcs.bf_getbuffer` and
:c:member:`~PyBufferProcs.bf_releasebuffer` are now available
under the :ref:`limited API <limited-c-api>`.
.. versionchanged:: 3.11
:c:member:`~PyBufferProcs.bf_getbuffer` and
:c:member:`~PyBufferProcs.bf_releasebuffer` are now available
under the :ref:`limited API <limited-c-api>`.
.. versionchanged:: 3.14
The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
using ``Py_tp_vectorcall``. See the field's documentation
for details.
.. versionchanged:: 3.14
The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
using ``Py_tp_vectorcall``. See the field's documentation
for details.
.. c:member:: void *pfunc
Expand Down
38 changes: 20 additions & 18 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ PyCapsule_IsValid:const char*:name::
PyCapsule_New:PyObject*::+1:
PyCapsule_New:void*:pointer::
PyCapsule_New:const char *:name::
PyCapsule_New::void (* destructor)(PyObject* )::
PyCapsule_New:void (*)(PyObject *):destructor::

PyCapsule_SetContext:int:::
PyCapsule_SetContext:PyObject*:self:0:
Expand Down Expand Up @@ -349,11 +349,11 @@ PyComplex_CheckExact:int:::
PyComplex_CheckExact:PyObject*:p:0:

PyComplex_FromCComplex:PyObject*::+1:
PyComplex_FromCComplex::Py_complex v::
PyComplex_FromCComplex:Py_complex:v::

PyComplex_FromDoubles:PyObject*::+1:
PyComplex_FromDoubles::double real::
PyComplex_FromDoubles::double imag::
PyComplex_FromDoubles:double:real::
PyComplex_FromDoubles:double:imag::

PyComplex_ImagAsDouble:double:::
PyComplex_ImagAsDouble:PyObject*:op:0:
Expand Down Expand Up @@ -620,7 +620,9 @@ PyErr_GetExcInfo:PyObject**:pvalue:+1:
PyErr_GetExcInfo:PyObject**:ptraceback:+1:

PyErr_GetRaisedException:PyObject*::+1:
PyErr_SetRaisedException::::

PyErr_SetRaisedException:void:::
PyErr_SetRaisedException:PyObject *:exc:0:stolen

PyErr_GivenExceptionMatches:int:::
PyErr_GivenExceptionMatches:PyObject*:given:0:
Expand All @@ -640,9 +642,9 @@ PyErr_NewExceptionWithDoc:PyObject*:dict:0:
PyErr_NoMemory:PyObject*::null:

PyErr_NormalizeException:void:::
PyErr_NormalizeException:PyObject**:exc::???
PyErr_NormalizeException:PyObject**:val::???
PyErr_NormalizeException:PyObject**:tb::???
PyErr_NormalizeException:PyObject**:exc:+1:???
PyErr_NormalizeException:PyObject**:val:+1:???
PyErr_NormalizeException:PyObject**:tb:+1:???

PyErr_Occurred:PyObject*::0:

Expand Down Expand Up @@ -1314,7 +1316,7 @@ PyMapping_GetItemString:const char*:key::

PyMapping_HasKey:int:::
PyMapping_HasKey:PyObject*:o:0:
PyMapping_HasKey:PyObject*:key::
PyMapping_HasKey:PyObject*:key:0:

PyMapping_HasKeyString:int:::
PyMapping_HasKeyString:PyObject*:o:0:
Expand Down Expand Up @@ -1474,7 +1476,7 @@ PyModule_GetState:void*:::
PyModule_GetState:PyObject*:module:0:

PyModule_New:PyObject*::+1:
PyModule_New::char* name::
PyModule_New:char*:name::

PyModule_NewObject:PyObject*::+1:
PyModule_NewObject:PyObject*:name:+1:
Expand Down Expand Up @@ -1984,10 +1986,10 @@ PyRun_StringFlags:PyObject*:locals:0:
PyRun_StringFlags:PyCompilerFlags*:flags::

PySeqIter_Check:int:::
PySeqIter_Check::op::
PySeqIter_Check:PyObject *:op:0:

PySeqIter_New:PyObject*::+1:
PySeqIter_New:PyObject*:seq::
PySeqIter_New:PyObject*:seq:0:

PySequence_Check:int:::
PySequence_Check:PyObject*:o:0:
Expand Down Expand Up @@ -2421,7 +2423,7 @@ PyUnicode_GET_LENGTH:PyObject*:o:0:
PyUnicode_KIND:int:::
PyUnicode_KIND:PyObject*:o:0:

PyUnicode_MAX_CHAR_VALUE::::
PyUnicode_MAX_CHAR_VALUE:Py_UCS4:::
PyUnicode_MAX_CHAR_VALUE:PyObject*:o:0:

Py_UNICODE_ISALNUM:int:::
Expand Down Expand Up @@ -2488,7 +2490,7 @@ PyUnicode_FromWideChar:const wchar_t*:w::
PyUnicode_FromWideChar:Py_ssize_t:size::

PyUnicode_AsWideChar:Py_ssize_t:::
PyUnicode_AsWideChar:PyObject*:*unicode:0:
PyUnicode_AsWideChar:PyObject*:unicode:0:
PyUnicode_AsWideChar:wchar_t*:w::
PyUnicode_AsWideChar:Py_ssize_t:size::

Expand Down Expand Up @@ -2541,7 +2543,7 @@ PyUnicode_AsUTF8String:PyObject*:unicode:0:

PyUnicode_AsUTF8AndSize:const char*:::
PyUnicode_AsUTF8AndSize:PyObject*:unicode:0:
PyUnicode_AsUTF8AndSize:Py_ssize_t*:size:0:
PyUnicode_AsUTF8AndSize:Py_ssize_t*:size::

PyUnicode_AsUTF8:const char*:::
PyUnicode_AsUTF8:PyObject*:unicode:0:
Expand Down Expand Up @@ -2864,13 +2866,13 @@ PyUnicodeDecodeError_SetStart:PyObject*:exc:0:
PyUnicodeDecodeError_SetStart:Py_ssize_t:start::

PyWeakref_Check:int:::
PyWeakref_Check:PyObject*:ob::
PyWeakref_Check:PyObject*:ob:0:

PyWeakref_CheckProxy:int:::
PyWeakref_CheckProxy:PyObject*:ob::
PyWeakref_CheckProxy:PyObject*:ob:0:

PyWeakref_CheckRef:int:::
PyWeakref_CheckRef:PyObject*:ob::
PyWeakref_CheckRef:PyObject*:ob:0:

PyWeakref_GET_OBJECT:PyObject*::0:
PyWeakref_GET_OBJECT:PyObject*:ref:0:
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/asyncio-sync.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,16 @@ Condition

Note that a task *may* return from this call spuriously,
which is why the caller should always re-check the state
and be prepared to :meth:`wait` again. For this reason, you may
prefer to use :meth:`wait_for` instead.
and be prepared to :meth:`~Condition.wait` again. For this reason, you may
prefer to use :meth:`~Condition.wait_for` instead.

.. coroutinemethod:: wait_for(predicate)

Wait until a predicate becomes *true*.

The predicate must be a callable which result will be
interpreted as a boolean value. The method will repeatedly
:meth:`wait` until the predicate evaluates to *true*. The final value is the
:meth:`~Condition.wait` until the predicate evaluates to *true*. The final value is the
return value.


Expand Down Expand Up @@ -434,7 +434,7 @@ Barrier
.. coroutinemethod:: abort()

Put the barrier into a broken state. This causes any active or future
calls to :meth:`wait` to fail with the :class:`BrokenBarrierError`.
calls to :meth:`~Barrier.wait` to fail with the :class:`BrokenBarrierError`.
Use this for example if one of the tasks needs to abort, to avoid infinite
waiting tasks.

Expand Down
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ sys
from other interpreters than the one it's called in.


tkinter
-------

* Make tkinter widget methods :meth:`!after` and :meth:`!after_idle` accept
arguments passed by keyword.
(Contributed by Zhikang Yan in :gh:`126899`.)


unicodedata
-----------

Expand Down
2 changes: 2 additions & 0 deletions Include/cpython/pystats.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ typedef struct _gc_stats {
uint64_t collections;
uint64_t object_visits;
uint64_t objects_collected;
uint64_t objects_transitively_reachable;
uint64_t objects_not_transitively_reachable;
} GCStats;

typedef struct _uop_stats {
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ typedef struct _PyInterpreterFrame {
_PyStackRef *stackpointer;
uint16_t return_offset; /* Only relevant during a function call */
char owner;
char visited;
/* Locals and stack */
_PyStackRef localsplus[1];
} _PyInterpreterFrame;
Expand Down Expand Up @@ -207,6 +208,7 @@ _PyFrame_Initialize(
#endif
frame->return_offset = 0;
frame->owner = FRAME_OWNED_BY_THREAD;
frame->visited = 0;

for (int i = null_locals_from; i < code->co_nlocalsplus; i++) {
frame->localsplus[i] = PyStackRef_NULL;
Expand Down Expand Up @@ -389,6 +391,7 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int
frame->instr_ptr = _PyCode_CODE(code);
#endif
frame->owner = FRAME_OWNED_BY_THREAD;
frame->visited = 0;
frame->return_offset = 0;

#ifdef Py_GIL_DISABLED
Expand Down
10 changes: 8 additions & 2 deletions Include/internal/pycore_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ extern "C" {

/* GC information is stored BEFORE the object structure. */
typedef struct {
// Pointer to next object in the list.
// Tagged pointer to next object in the list.
// 0 means the object is not tracked
uintptr_t _gc_next;

// Pointer to previous object in the list.
// Tagged pointer to previous object in the list.
// Lowest two bits are used for flags documented later.
uintptr_t _gc_prev;
} PyGC_Head;
Expand Down Expand Up @@ -284,6 +284,11 @@ struct gc_generation_stats {
Py_ssize_t uncollectable;
};

enum _GCPhase {
GC_PHASE_MARK = 0,
GC_PHASE_COLLECT = 1
};

struct _gc_runtime_state {
/* List of objects that still need to be cleaned up, singly linked
* via their gc headers' gc_prev pointers. */
Expand Down Expand Up @@ -311,6 +316,7 @@ struct _gc_runtime_state {
Py_ssize_t work_to_do;
/* Which of the old spaces is the visited space */
int visited_space;
int phase;

#ifdef Py_GIL_DISABLED
/* This is the number of objects that survived the last full
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ extern "C" {

PyAPI_FUNC(PyObject*) _PyList_Extend(PyListObject *, PyObject *);
extern void _PyList_DebugMallocStats(FILE *out);
// _PyList_GetItemRef should be used only when the object is known as a list
// because it doesn't raise TypeError when the object is not a list, whereas PyList_GetItemRef does.
extern PyObject* _PyList_GetItemRef(PyListObject *, Py_ssize_t i);

#define _PyList_ITEMS(op) _Py_RVALUE(_PyList_CAST(op)->ob_item)

Expand Down
4 changes: 2 additions & 2 deletions Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ static inline void _PyObject_GC_TRACK(
PyGC_Head *last = (PyGC_Head*)(generation0->_gc_prev);
_PyGCHead_SET_NEXT(last, gc);
_PyGCHead_SET_PREV(gc, last);
/* Young objects will be moved into the visited space during GC, so set the bit here */
gc->_gc_next = ((uintptr_t)generation0) | (uintptr_t)interp->gc.visited_space;
uintptr_t not_visited = 1 ^ interp->gc.visited_space;
gc->_gc_next = ((uintptr_t)generation0) | not_visited;
generation0->_gc_prev = (uintptr_t)gc;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Include/internal/pycore_runtime_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ extern PyTypeObject _PyExc_MemoryError;
{ .threshold = 0, }, \
}, \
.work_to_do = -5000, \
.phase = GC_PHASE_MARK, \
}, \
.qsbr = { \
.wr_seq = QSBR_INITIAL, \
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion InternalDocs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# CPython Internals Documentation

The documentation in this folder is intended for CPython maintainers.
Expand Down
Loading

0 comments on commit 3ac1ff1

Please sign in to comment.