Skip to content
Merged
2 changes: 1 addition & 1 deletion Doc/c-api/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bound into a function.
Type of a code object watcher callback function.

If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked
after `co` has been fully initialized. Otherwise, the callback is invoked
after *co* has been fully initialized. Otherwise, the callback is invoked
before the destruction of *co* takes place, so the prior state of *co*
can be inspected.

Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ There are a few functions specific to Python functions.
unpredictable effects, including infinite recursion.

If *event* is ``PyFunction_EVENT_CREATE``, then the callback is invoked
after `func` has been fully initialized. Otherwise, the callback is invoked
after *func* has been fully initialized. Otherwise, the callback is invoked
before the modification to *func* takes place, so the prior state of *func*
can be inspected. The runtime is permitted to optimize away the creation of
function objects when possible. In such cases no event will be emitted.
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)

.. c:macro:: Py_TPFLAGS_MANAGED_DICT

This bit indicates that instances of the class have a `~object.__dict__`
This bit indicates that instances of the class have a :attr:`~object.__dict__`
attribute, and that the space for the dictionary is managed by the VM.

If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set.
Expand Down
4 changes: 4 additions & 0 deletions Doc/library/annotationlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ Classes
means may not have any information about their scope, so passing
arguments to this method may be necessary to evaluate them successfully.

If no *owner*, *globals*, *locals*, or *type_params* are provided and the
:class:`~ForwardRef` does not contain information about its origin,
empty globals and locals dictionaries are used.

.. versionadded:: 3.14


Expand Down
15 changes: 3 additions & 12 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3500,20 +3500,11 @@ Introspection helpers
Evaluate an :class:`annotationlib.ForwardRef` as a :term:`type hint`.

This is similar to calling :meth:`annotationlib.ForwardRef.evaluate`,
but unlike that method, :func:`!evaluate_forward_ref` also:

* Recursively evaluates forward references nested within the type hint.
* Raises :exc:`TypeError` when it encounters certain objects that are
not valid type hints.
* Replaces type hints that evaluate to :const:`!None` with
:class:`types.NoneType`.
* Supports the :attr:`~annotationlib.Format.FORWARDREF` and
:attr:`~annotationlib.Format.STRING` formats.
but unlike that method, :func:`!evaluate_forward_ref` also
recursively evaluates forward references nested within the type hint.

See the documentation for :meth:`annotationlib.ForwardRef.evaluate` for
the meaning of the *owner*, *globals*, *locals*, and *type_params* parameters.
*format* specifies the format of the annotation and is a member of
the :class:`annotationlib.Format` enum.
the meaning of the *owner*, *globals*, *locals*, *type_params*, and *format* parameters.

.. versionadded:: 3.14

Expand Down
2 changes: 2 additions & 0 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ typedef struct _stack_chunk {
PyObject * data[1]; /* Variable sized */
} _PyStackChunk;

/* Minimum size of data stack chunk */
#define _PY_DATA_STACK_CHUNK_SIZE (16*1024)
struct _ts {
/* See Python/ceval.c for comments explaining most fields */

Expand Down
15 changes: 15 additions & 0 deletions Include/internal/pycore_debug_offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ extern "C" {
# define _Py_Debug_Free_Threaded 1
# define _Py_Debug_code_object_co_tlbc offsetof(PyCodeObject, co_tlbc)
# define _Py_Debug_interpreter_frame_tlbc_index offsetof(_PyInterpreterFrame, tlbc_index)
# define _Py_Debug_interpreter_state_tlbc_generation offsetof(PyInterpreterState, tlbc_indices.tlbc_generation)
#else
# define _Py_Debug_gilruntimestate_enabled 0
# define _Py_Debug_Free_Threaded 0
# define _Py_Debug_code_object_co_tlbc 0
# define _Py_Debug_interpreter_frame_tlbc_index 0
# define _Py_Debug_interpreter_state_tlbc_generation 0
#endif


Expand Down Expand Up @@ -89,6 +91,8 @@ typedef struct _Py_DebugOffsets {
uint64_t gil_runtime_state_enabled;
uint64_t gil_runtime_state_locked;
uint64_t gil_runtime_state_holder;
uint64_t code_object_generation;
uint64_t tlbc_generation;
} interpreter_state;

// Thread state offset;
Expand Down Expand Up @@ -216,6 +220,11 @@ typedef struct _Py_DebugOffsets {
uint64_t gi_frame_state;
} gen_object;

struct _llist_node {
uint64_t next;
uint64_t prev;
} llist_node;

struct _debugger_support {
uint64_t eval_breaker;
uint64_t remote_debugger_support;
Expand Down Expand Up @@ -251,6 +260,8 @@ typedef struct _Py_DebugOffsets {
.gil_runtime_state_enabled = _Py_Debug_gilruntimestate_enabled, \
.gil_runtime_state_locked = offsetof(PyInterpreterState, _gil.locked), \
.gil_runtime_state_holder = offsetof(PyInterpreterState, _gil.last_holder), \
.code_object_generation = offsetof(PyInterpreterState, _code_object_generation), \
.tlbc_generation = _Py_Debug_interpreter_state_tlbc_generation, \
}, \
.thread_state = { \
.size = sizeof(PyThreadState), \
Expand Down Expand Up @@ -347,6 +358,10 @@ typedef struct _Py_DebugOffsets {
.gi_iframe = offsetof(PyGenObject, gi_iframe), \
.gi_frame_state = offsetof(PyGenObject, gi_frame_state), \
}, \
.llist_node = { \
.next = offsetof(struct llist_node, next), \
.prev = offsetof(struct llist_node, prev), \
}, \
.debugger_support = { \
.eval_breaker = offsetof(PyThreadState, eval_breaker), \
.remote_debugger_support = offsetof(PyThreadState, remote_debugger_support), \
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_global_objects_fini_generated.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_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(alias)
STRUCT_FOR_ID(align)
STRUCT_FOR_ID(all)
STRUCT_FOR_ID(all_threads)
STRUCT_FOR_ID(allow_code)
STRUCT_FOR_ID(any)
STRUCT_FOR_ID(append)
Expand Down
6 changes: 6 additions & 0 deletions Include/internal/pycore_interp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@ typedef struct _PyIndexPool {

// Next index to allocate if no free indices are available
int32_t next_index;

// Generation counter incremented on thread creation/destruction
// Used for TLBC cache invalidation in remote debugging
uint32_t tlbc_generation;
} _PyIndexPool;

typedef union _Py_unique_id_entry {
Expand Down Expand Up @@ -843,6 +847,8 @@ struct _is {
/* The per-interpreter GIL, which might not be used. */
struct _gil_runtime_state _gil;

uint64_t _code_object_generation;

/* ---------- IMPORTANT ---------------------------
The fields above this line are declared as early as
possible to facilitate out-of-process observability
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_runtime_init_generated.h

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

4 changes: 4 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

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

8 changes: 6 additions & 2 deletions Lib/asyncio/tools.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Tools to analyze tasks running in asyncio programs."""

from dataclasses import dataclass
from collections import defaultdict
from itertools import count
from enum import Enum
import sys
from _remote_debugging import get_all_awaited_by
from _remote_debugging import RemoteUnwinder


class NodeType(Enum):
Expand Down Expand Up @@ -118,6 +117,11 @@ def dfs(v):


# ─── PRINT TREE FUNCTION ───────────────────────────────────────
def get_all_awaited_by(pid):
unwinder = RemoteUnwinder(pid)
return unwinder.get_all_awaited_by()


def build_async_tree(result, task_emoji="(T)", cor_emoji=""):
"""
Build a list of strings for pretty-print an async call tree.
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/.ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ extend-exclude = [

[lint]
select = [
"F401", # Unused import
"F811", # Redefinition of unused variable (useful for finding test methods with the same name)
]

[lint.per-file-ignores]
"*/**/__main__.py" = ["F401"] # Unused import
"test_import/*.py" = ["F401"] # Unused import
"test_importlib/*.py" = ["F401"] # Unused import
"typinganndata/partialexecution/*.py" = ["F401"] # Unused import
3 changes: 1 addition & 2 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,6 @@ def __init__(self):
self.started = False

def start(self):
import warnings
try:
f = open(self.procfile, 'r')
except OSError as e:
Expand Down Expand Up @@ -2728,7 +2727,7 @@ def iter_builtin_types():
# Fall back to making a best-effort guess.
if hasattr(object, '__flags__'):
# Look for any type object with the Py_TPFLAGS_STATIC_BUILTIN flag set.
import datetime
import datetime # noqa: F401
seen = set()
for cls, subs in walk_class_hierarchy(object):
if cls in seen:
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/support/interpreters/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

# aliases:
from _interpchannels import (
ChannelError, ChannelNotFoundError, ChannelClosedError,
ChannelEmptyError, ChannelNotEmptyError,
ChannelError, ChannelNotFoundError, ChannelClosedError, # noqa: F401
ChannelEmptyError, ChannelNotEmptyError, # noqa: F401
)
from ._crossinterp import (
UNBOUND_ERROR, UNBOUND_REMOVE,
Expand Down
1 change: 0 additions & 1 deletion Lib/test/support/interpreters/queues.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Cross-interpreter Queues High Level Module."""

import pickle
import queue
import time
import weakref
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_capi/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import os
import sys
import sysconfig
import types
import unittest
from test import support
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_codeccallbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import codecs
import html.entities
import itertools
import re
import sys
import unicodedata
import unittest
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_crossinterp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import contextlib
import importlib
import importlib.util
import itertools
import sys
import types
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_ctypes/_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ctypes
from _ctypes import Structure, Union, _Pointer, Array, _SimpleCData, CFuncPtr
import sys
from test import support


_CData = Structure.__base__
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_ctypes/test_byteswap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import binascii
import ctypes
import math
import struct
import sys
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_ctypes/test_generated_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""

import unittest
from test.support import import_helper, verbose
from test.support import import_helper
import re
from dataclasses import dataclass
from functools import cached_property
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import math
import os, sys
import operator
import warnings
import pickle, copy
import unittest
import numbers
Expand Down
Loading
Loading