diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index da04cfde3bd587..386b2dd50fd462 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1638,6 +1638,7 @@ and are also passed to registered trace functions. single: f_locals (frame attribute) single: f_lasti (frame attribute) single: f_builtins (frame attribute) + single: f_generator (frame attribute) Special read-only attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1674,6 +1675,10 @@ Special read-only attributes - The "precise instruction" of the frame object (this is an index into the :term:`bytecode` string of the :ref:`code object `) + + * - .. attribute:: frame.f_generator + - Returns the generator or coroutine object that owns this frame, + or ``None`` if the frame is of a regular function. .. index:: single: f_trace (frame attribute) diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py index 68d6bad2094268..e76f79c274e744 100644 --- a/Lib/test/list_tests.py +++ b/Lib/test/list_tests.py @@ -32,13 +32,13 @@ def test_init(self): self.assertEqual(a, b) def test_getitem_error(self): - a = [] + a = self.type2test([]) msg = "list indices must be integers or slices" with self.assertRaisesRegex(TypeError, msg): a['a'] def test_setitem_error(self): - a = [] + a = self.type2test([]) msg = "list indices must be integers or slices" with self.assertRaisesRegex(TypeError, msg): a['a'] = "python" @@ -561,7 +561,7 @@ def test_constructor_exception_handling(self): class F(object): def __iter__(self): raise KeyboardInterrupt - self.assertRaises(KeyboardInterrupt, list, F()) + self.assertRaises(KeyboardInterrupt, self.type2test, F()) def test_exhausted_iterator(self): a = self.type2test([1, 2, 3])