Skip to content

Commit 24cd9d8

Browse files
Address review
1 parent 8f2d85e commit 24cd9d8

2 files changed

Lines changed: 1 addition & 23 deletions

File tree

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import unittest
2-
import threading
32
from typing import TypeVar
43
from test.support import threading_helper
54

65
threading_helper.requires_working_threading(module=True)
76

8-
NTHREADS = 10
9-
107

118
class TestGenericAlias(unittest.TestCase):
129
def test_parameters_race(self):
@@ -31,24 +28,6 @@ def refresh():
3128
*[refresh for _ in range(2)],
3229
])
3330

34-
def test_shared_generic_alias_iter(self):
35-
# See https://github.com/python/cpython/issues/154043
36-
def worker(it, barrier):
37-
barrier.wait()
38-
try:
39-
next(it)
40-
except StopIteration:
41-
pass
42-
bar = threading.Barrier(NTHREADS)
43-
44-
bar = threading.Barrier(NTHREADS)
45-
number_of_iterations = 50
46-
for _ in range(number_of_iterations):
47-
shared = iter(list[int])
48-
threading_helper.run_concurrently(
49-
worker_func=worker, nthreads=NTHREADS, args=(shared, bar)
50-
)
51-
5231

5332
if __name__ == "__main__":
5433
unittest.main()

Objects/genericaliasobject.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,12 +951,11 @@ ga_iternext(PyObject *op)
951951
}
952952
gaobject *alias = (gaobject *)obj;
953953
PyObject *starred_alias = Py_GenericAlias(alias->origin, alias->args);
954+
Py_DECREF(obj);
954955
if (starred_alias == NULL) {
955-
Py_DECREF(obj);
956956
return NULL;
957957
}
958958
((gaobject *)starred_alias)->starred = true;
959-
Py_SETREF(obj, NULL);
960959
return starred_alias;
961960
}
962961

0 commit comments

Comments
 (0)