Skip to content

Commit c719cc5

Browse files
authored
Merge branch '3.12' into backport-8a00c9a-3.12
2 parents 43af621 + d4ddc03 commit c719cc5

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed

Lib/test/test_asyncio/test_tasks.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for tasks.py."""
22

33
import collections
4+
import contextlib
45
import contextvars
56
import gc
67
import io
@@ -2499,17 +2500,17 @@ def __str__(self):
24992500
initial_refcount = sys.getrefcount(obj)
25002501

25012502
coro = coroutine_function()
2502-
loop = asyncio.new_event_loop()
2503-
task = asyncio.Task.__new__(asyncio.Task)
2503+
with contextlib.closing(asyncio.new_event_loop()) as loop:
2504+
task = asyncio.Task.__new__(asyncio.Task)
25042505

2505-
for _ in range(5):
2506-
with self.assertRaisesRegex(RuntimeError, 'break'):
2507-
task.__init__(coro, loop=loop, context=obj, name=Break())
2506+
for _ in range(5):
2507+
with self.assertRaisesRegex(RuntimeError, 'break'):
2508+
task.__init__(coro, loop=loop, context=obj, name=Break())
25082509

2509-
coro.close()
2510-
del task
2510+
coro.close()
2511+
del task
25112512

2512-
self.assertEqual(sys.getrefcount(obj), initial_refcount)
2513+
self.assertEqual(sys.getrefcount(obj), initial_refcount)
25132514

25142515

25152516
def add_subclass_tests(cls):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update PyUnstable_GC_VisitObjects to traverse perm gen.

Modules/gcmodule.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,6 +2443,23 @@ PyObject_GC_IsFinalized(PyObject *obj)
24432443
return 0;
24442444
}
24452445

2446+
static int
2447+
visit_generation(gcvisitobjects_t callback, void *arg, struct gc_generation *gen)
2448+
{
2449+
PyGC_Head *gc_list, *gc;
2450+
gc_list = &gen->head;
2451+
for (gc = GC_NEXT(gc_list); gc != gc_list; gc = GC_NEXT(gc)) {
2452+
PyObject *op = FROM_GC(gc);
2453+
Py_INCREF(op);
2454+
int res = callback(op, arg);
2455+
Py_DECREF(op);
2456+
if (!res) {
2457+
return -1;
2458+
}
2459+
}
2460+
return 0;
2461+
}
2462+
24462463
void
24472464
PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg)
24482465
{
@@ -2451,18 +2468,11 @@ PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg)
24512468
int origenstate = gcstate->enabled;
24522469
gcstate->enabled = 0;
24532470
for (i = 0; i < NUM_GENERATIONS; i++) {
2454-
PyGC_Head *gc_list, *gc;
2455-
gc_list = GEN_HEAD(gcstate, i);
2456-
for (gc = GC_NEXT(gc_list); gc != gc_list; gc = GC_NEXT(gc)) {
2457-
PyObject *op = FROM_GC(gc);
2458-
Py_INCREF(op);
2459-
int res = callback(op, arg);
2460-
Py_DECREF(op);
2461-
if (!res) {
2462-
goto done;
2463-
}
2471+
if (visit_generation(callback, arg, &gcstate->generations[i])) {
2472+
goto done;
24642473
}
24652474
}
2475+
visit_generation(callback, arg, &gcstate->permanent_generation);
24662476
done:
24672477
gcstate->enabled = origenstate;
24682478
}

Python/initconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Options (and corresponding environment variables):\n\
4444
-h : print this help message and exit (also -? or --help)\n\
4545
-i : inspect interactively after running script; forces a prompt even\n\
4646
if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\
47-
-I : isolate Python from the user's environment (implies -E and -s)\n\
47+
-I : isolate Python from the user's environment (implies -E, -P and -s)\n\
4848
-m mod : run library module as a script (terminates option list)\n\
4949
-O : remove assert and __debug__-dependent statements; add .opt-1 before\n\
5050
.pyc extension; also PYTHONOPTIMIZE=x\n\

Tools/build/compute-changes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def compute_changes() -> None:
6565
outputs = process_changed_files(files)
6666
else:
6767
# Otherwise, just run the tests
68-
outputs = Outputs(run_tests=True)
68+
outputs = Outputs(run_tests=True, run_windows_tests=True)
6969
outputs = process_target_branch(outputs, target_branch)
7070

7171
if outputs.run_tests:

0 commit comments

Comments
 (0)