Skip to content

Commit 7348111

Browse files
Review addressed
1 parent 89d4062 commit 7348111

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

Lib/test/test_builtin.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,21 @@ def test_map_strict(self):
13851385
self.assertRaises(ValueError, tuple,
13861386
map(pack, (1, 2), (1, 2), 'abc', strict=True))
13871387

1388+
t1 = (None, object())
1389+
t2 = (object(), object())
1390+
t3 = (object(),)
1391+
1392+
self.assertRaises(ValueError, tuple,
1393+
map(pack, t1, 'a', strict=True))
1394+
self.assertRaises(ValueError, tuple,
1395+
map(pack, t1, t2, 'a', strict=True))
1396+
self.assertRaises(ValueError, tuple,
1397+
map(pack, t1, t2, t3, strict=True))
1398+
self.assertRaises(ValueError, tuple,
1399+
map(pack, 'a', t1, strict=True))
1400+
self.assertRaises(ValueError, tuple,
1401+
map(pack, 'a', t2, t3, strict=True))
1402+
13881403
def test_map_strict_iterators(self):
13891404
x = iter(range(5))
13901405
y = [0]
@@ -1457,23 +1472,6 @@ def __next__(self):
14571472
l8 = self.iter_error(map(pack, Iter(3), "AB", strict=True), ValueError)
14581473
self.assertEqual(l8, [(2, "A"), (1, "B")])
14591474

1460-
# gh-140517: fix refcount leak
1461-
def test_map_strict_noleak(self):
1462-
t1 = (None, object())
1463-
t2 = (object(), object())
1464-
t3 = (object(),)
1465-
1466-
self.assertRaises(ValueError, tuple,
1467-
map(pack, t1, 'a', strict=True))
1468-
self.assertRaises(ValueError, tuple,
1469-
map(pack, t1, t2, 'a', strict=True))
1470-
self.assertRaises(ValueError, tuple,
1471-
map(pack, t1, t2, t3, strict=True))
1472-
self.assertRaises(ValueError, tuple,
1473-
map(pack, 'a', t1, strict=True))
1474-
self.assertRaises(ValueError, tuple,
1475-
map(pack, 'a', t2, t3, strict=True))
1476-
14771475
def test_max(self):
14781476
self.assertEqual(max('123123'), '3')
14791477
self.assertEqual(max(1, 2, 3), 3)

Python/bltinmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ map_next(PyObject *self)
15211521
if (PyErr_Occurred()) {
15221522
if (!PyErr_ExceptionMatches(PyExc_StopIteration)) {
15231523
// next() on argument i raised an exception (not StopIteration)
1524-
// result is NULL;
1524+
assert(result == NULL);
15251525
goto exit;
15261526
}
15271527
PyErr_Clear();
@@ -1549,14 +1549,16 @@ map_next(PyObject *self)
15491549
if (PyErr_Occurred()) {
15501550
if (!PyErr_ExceptionMatches(PyExc_StopIteration)) {
15511551
// next() on argument i raised an exception (not StopIteration)
1552-
// result is NULL;
1552+
assert(result == NULL);
15531553
goto exit;
15541554
}
15551555
PyErr_Clear();
15561556
}
15571557
// Argument i is exhausted. So far so good...
15581558
}
15591559
// All arguments are exhausted. Success!
1560+
assert(result == NULL);
1561+
15601562
exit:
15611563
for (i=0; i < nargs; i++) {
15621564
Py_DECREF(stack[i]);

0 commit comments

Comments
 (0)