This commit is contained in:
Pablo Galindo Salgado 2025-12-07 23:40:04 +00:00
parent 12c02f6612
commit c10628acb7
5 changed files with 39 additions and 0 deletions

View file

@ -1937,6 +1937,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(only_keys));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(oparg));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(opcode));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(opcodes));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(open));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(opener));
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(operation));

View file

@ -660,6 +660,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(only_keys)
STRUCT_FOR_ID(oparg)
STRUCT_FOR_ID(opcode)
STRUCT_FOR_ID(opcodes)
STRUCT_FOR_ID(open)
STRUCT_FOR_ID(opener)
STRUCT_FOR_ID(operation)

View file

@ -1935,6 +1935,7 @@ extern "C" {
INIT_ID(only_keys), \
INIT_ID(oparg), \
INIT_ID(opcode), \
INIT_ID(opcodes), \
INIT_ID(open), \
INIT_ID(opener), \
INIT_ID(operation), \

View file

@ -2420,6 +2420,10 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(opcodes);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));
assert(PyUnicode_GET_LENGTH(string) != 1);
string = &_Py_ID(open);
_PyUnicode_InternStatic(interp, &string);
assert(_PyUnicode_CheckConsistency(string, 1));

View file

@ -1,11 +1,43 @@
"""Common test helpers and mocks for live collector tests."""
from collections import namedtuple
from profiling.sampling.constants import (
THREAD_STATUS_HAS_GIL,
THREAD_STATUS_ON_CPU,
)
# Matches the C structseq LocationInfo from _remote_debugging
LocationInfo = namedtuple('LocationInfo', ['lineno', 'end_lineno', 'col_offset', 'end_col_offset'])
class MockFrameInfo:
"""Mock FrameInfo for testing.
Frame format: (filename, location, funcname, opcode) where:
- location is a tuple (lineno, end_lineno, col_offset, end_col_offset)
- opcode is an int or None
"""
def __init__(self, filename, lineno, funcname, opcode=None):
self.filename = filename
self.funcname = funcname
self.opcode = opcode
self.location = LocationInfo(lineno, lineno, -1, -1)
def __iter__(self):
return iter((self.filename, self.location, self.funcname, self.opcode))
def __getitem__(self, index):
return (self.filename, self.location, self.funcname, self.opcode)[index]
def __len__(self):
return 4
def __repr__(self):
return f"MockFrameInfo('{self.filename}', {self.location}, '{self.funcname}', {self.opcode})"
class MockThreadInfo:
"""Mock ThreadInfo for testing."""