Skip to content

Commit 076bdc0

Browse files
Merge branch 'main' into new-fix-issue-127011
2 parents df4bf21 + 4c20f46 commit 076bdc0

16 files changed

Lines changed: 327 additions & 361 deletions

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ extern "C" {
99

1010
#include "pycore_ast_state.h" // struct ast_state
1111
#include "pycore_llist.h" // struct llist_node
12-
#include "pycore_memoryobject.h" // struct _memoryobject_state
1312
#include "pycore_opcode_utils.h" // NUM_COMMON_CONSTANTS
1413
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
1514
#include "pycore_structs.h" // PyHamtObject
@@ -913,10 +912,9 @@ struct _is {
913912
struct _dtoa_state dtoa;
914913
struct _py_func_state func_state;
915914
struct _py_code_state code_state;
915+
916916
struct _Py_dict_state dict_state;
917917
struct _Py_exc_state exc_state;
918-
struct _memoryobject_state memobj_state;
919-
920918
struct _Py_mem_interp_free_queue mem_free_queue;
921919

922920
struct ast_state ast;

Include/internal/pycore_memoryobject.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
struct _memoryobject_state {
12-
PyTypeObject *XIBufferViewType;
13-
};
14-
15-
extern PyStatus _PyMemoryView_InitTypes(PyInterpreterState *);
16-
extern void _PyMemoryView_FiniTypes(PyInterpreterState *);
17-
18-
// exported for _interpreters module
19-
PyAPI_FUNC(PyTypeObject *) _PyMemoryView_GetXIBuffewViewType(void);
20-
21-
2211
extern PyTypeObject _PyManagedBuffer_Type;
2312

2413
PyObject *

Lib/test/pythoninfo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def collect_sys(info_add):
146146
text = 'No (sys.getobjects() missing)'
147147
info_add('build.Py_TRACE_REFS', text)
148148

149+
info_add('sys.is_remote_debug_enabled', sys.is_remote_debug_enabled())
150+
149151

150152
def collect_platform(info_add):
151153
import platform
@@ -528,6 +530,7 @@ def collect_sysconfig(info_add):
528530
'Py_DEBUG',
529531
'Py_ENABLE_SHARED',
530532
'Py_GIL_DISABLED',
533+
'Py_REMOTE_DEBUG',
531534
'SHELL',
532535
'SOABI',
533536
'TEST_MODULES',

Lib/test/test_capi/test_opt.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,18 @@ def testfunc(n):
19111911
self.assertNotIn("_COMPARE_OP_INT", uops)
19121912
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
19131913

1914+
def test_call_len(self):
1915+
def testfunc(n):
1916+
a = [1, 2, 3, 4]
1917+
for _ in range(n):
1918+
_ = len(a) - 1
1919+
1920+
_, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1921+
uops = get_opnames(ex)
1922+
self.assertNotIn("_GUARD_NOS_INT", uops)
1923+
self.assertNotIn("_GUARD_TOS_INT", uops)
1924+
self.assertIn("_CALL_LEN", uops)
1925+
19141926

19151927
def global_identity(x):
19161928
return x

Lib/test/test_remote_pdb.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
from pdb import _PdbServer, _PdbClient
2222

2323

24+
if not sys.is_remote_debug_enabled():
25+
raise unittest.SkipTest('remote debugging is disabled')
26+
27+
2428
@contextmanager
2529
def kill_on_error(proc):
2630
"""Context manager killing the subprocess if a Python exception is raised."""
@@ -465,12 +469,6 @@ def test_breakpoints(self):
465469

466470
def test_keyboard_interrupt(self):
467471
"""Test that sending keyboard interrupt breaks into pdb."""
468-
synchronizer_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
469-
synchronizer_sock.bind(('127.0.0.1', 0)) # Let OS assign port
470-
synchronizer_sock.settimeout(SHORT_TIMEOUT)
471-
synchronizer_sock.listen(1)
472-
self.addCleanup(synchronizer_sock.close)
473-
sync_port = synchronizer_sock.getsockname()[1]
474472

475473
script = textwrap.dedent(f"""
476474
import time
@@ -487,11 +485,10 @@ def bar():
487485
version=pdb._PdbServer.protocol_version(),
488486
)
489487
print("Connected to debugger")
490-
iterations = 10
491-
socket.create_connection(('127.0.0.1', {sync_port})).close()
488+
iterations = 50
492489
while iterations > 0:
493-
print("Iteration", iterations)
494-
time.sleep(1)
490+
print("Iteration", iterations, flush=True)
491+
time.sleep(0.2)
495492
iterations -= 1
496493
return 42
497494
@@ -508,22 +505,20 @@ def bar():
508505
# Continue execution
509506
self._send_command(client_file, "c")
510507

511-
# Wait until execution has continued
512-
synchronizer_sock.accept()[0].close()
513-
514-
# Wait a bit so the remote leaves create_connection(). This is not
515-
# required but makes the rest of the test faster as we will exit the main
516-
# loop immediately by setting iterations to 0.
517-
time.sleep(0.1)
508+
# Confirm that the remote is already in the while loop. We know
509+
# it's in bar() and we can exit the loop immediately by setting
510+
# iterations to 0.
511+
while line := process.stdout.readline():
512+
if line.startswith("Iteration"):
513+
break
518514

519515
# Inject a script to interrupt the running process
520516
self._send_interrupt(process.pid)
521517
messages = self._read_until_prompt(client_file)
522518

523-
# Verify we got the keyboard interrupt message. Is possible that we get interrupted somewhere
524-
# in bar() or when leving create_connection()
519+
# Verify we got the keyboard interrupt message.
525520
interrupt_msgs = [msg['message'] for msg in messages if 'message' in msg]
526-
expected_msg = [msg for msg in interrupt_msgs if "bar()" in msg or "create_connection()" in msg]
521+
expected_msg = [msg for msg in interrupt_msgs if "bar()" in msg]
527522
self.assertGreater(len(expected_msg), 0)
528523

529524
# Continue to end as fast as we can
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow the JIT to remove int guards after ``_CALL_LEN`` by setting the return type to int. Patch by Diego Russo

Modules/_asynciomodule.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ typedef struct {
185185
/* Counter for autogenerated Task names */
186186
uint64_t task_name_counter;
187187

188+
/* Pointer to the asyncio debug offset to avoid it to be optimized away
189+
by the compiler */
190+
void *debug_offsets;
191+
188192
} asyncio_state;
189193

190194
static inline asyncio_state *
@@ -4320,6 +4324,8 @@ module_init(asyncio_state *state)
43204324
goto fail;
43214325
}
43224326

4327+
state->debug_offsets = &_AsyncioDebug;
4328+
43234329
Py_DECREF(module);
43244330
return 0;
43254331

Modules/_interpreters_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
_RESOLVE_MODINIT_FUNC_NAME(NAME)
66

77

8-
#ifdef REGISTERS_HEAP_TYPES
98
static int
109
ensure_xid_class(PyTypeObject *cls, xidatafunc getdata)
1110
{
@@ -17,6 +16,7 @@ ensure_xid_class(PyTypeObject *cls, xidatafunc getdata)
1716
return _PyXIData_RegisterClass(&ctx, cls, getdata);
1817
}
1918

19+
#ifdef REGISTERS_HEAP_TYPES
2020
static int
2121
clear_xid_class(PyTypeObject *cls)
2222
{

0 commit comments

Comments
 (0)