From cd69f5b858b9636c5aea1766ccdb5cccca169828 Mon Sep 17 00:00:00 2001 From: Devansh Baghla Date: Fri, 5 Sep 2025 18:41:24 +0530 Subject: [PATCH 1/3] Docs: add f_generator attribute to datamodel page and update index --- Doc/reference/datamodel.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index da04cfde3bd587..faf2ee2b519d4a 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1633,6 +1633,7 @@ and are also passed to registered trace functions. .. index:: single: f_back (frame attribute) + single: f_generator (frame attribute) single: f_code (frame attribute) single: f_globals (frame attribute) single: f_locals (frame attribute) @@ -1648,6 +1649,10 @@ Special read-only attributes - Points to the previous stack frame (towards the caller), or ``None`` if this is the bottom stack frame + * - .. attribute:: frame.f_generator + - Returns the generator or coroutine object that owns this frame, + or ``None`` if the frame is of a regular function. + * - .. attribute:: frame.f_code - The :ref:`code object ` being executed in this frame. Accessing this attribute raises an :ref:`auditing event ` From c8c995603a953c6c1fd9aeeeb288eaa902e340f2 Mon Sep 17 00:00:00 2001 From: Devansh Baghla Date: Fri, 5 Sep 2025 18:58:02 +0530 Subject: [PATCH 2/3] Docs: move f_generator attribute to end of datamodel page --- Doc/reference/datamodel.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index faf2ee2b519d4a..386b2dd50fd462 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1633,12 +1633,12 @@ and are also passed to registered trace functions. .. index:: single: f_back (frame attribute) - single: f_generator (frame attribute) single: f_code (frame attribute) single: f_globals (frame attribute) single: f_locals (frame attribute) single: f_lasti (frame attribute) single: f_builtins (frame attribute) + single: f_generator (frame attribute) Special read-only attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1649,10 +1649,6 @@ Special read-only attributes - Points to the previous stack frame (towards the caller), or ``None`` if this is the bottom stack frame - * - .. attribute:: frame.f_generator - - Returns the generator or coroutine object that owns this frame, - or ``None`` if the frame is of a regular function. - * - .. attribute:: frame.f_code - The :ref:`code object ` being executed in this frame. Accessing this attribute raises an :ref:`auditing event ` @@ -1679,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) From 4afdb78233e5f7f434d15f574324a6a805eb1f63 Mon Sep 17 00:00:00 2001 From: Devansh Baghla Date: Sat, 6 Sep 2025 22:26:15 +0530 Subject: [PATCH 3/3] Use self.type2test in list_tests.CommonTest --- Lib/test/list_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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])