mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
bpo-46510: Add missing test for types.TracebackType/FrameType. Calculate them directly from the caught exception. (GH-30880)
This commit is contained in:
parent
d69d3d8b2f
commit
ec7c17ea23
3 changed files with 14 additions and 5 deletions
|
@ -624,6 +624,14 @@ class TypesTests(unittest.TestCase):
|
||||||
def test_none_type(self):
|
def test_none_type(self):
|
||||||
self.assertIsInstance(None, types.NoneType)
|
self.assertIsInstance(None, types.NoneType)
|
||||||
|
|
||||||
|
def test_traceback_and_frame_types(self):
|
||||||
|
try:
|
||||||
|
raise OSError
|
||||||
|
except OSError as e:
|
||||||
|
exc = e
|
||||||
|
self.assertIsInstance(exc.__traceback__, types.TracebackType)
|
||||||
|
self.assertIsInstance(exc.__traceback__.tb_frame, types.FrameType)
|
||||||
|
|
||||||
|
|
||||||
class UnionTests(unittest.TestCase):
|
class UnionTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,9 @@ ModuleType = type(sys)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
raise TypeError
|
raise TypeError
|
||||||
except TypeError:
|
except TypeError as exc:
|
||||||
tb = sys.exc_info()[2]
|
TracebackType = type(exc.__traceback__)
|
||||||
TracebackType = type(tb)
|
FrameType = type(exc.__traceback__.tb_frame)
|
||||||
FrameType = type(tb.tb_frame)
|
|
||||||
tb = None; del tb
|
|
||||||
|
|
||||||
# For Jython, the following two types are identical
|
# For Jython, the following two types are identical
|
||||||
GetSetDescriptorType = type(FunctionType.__code__)
|
GetSetDescriptorType = type(FunctionType.__code__)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Add missing test for :class:`types.TracebackType` and
|
||||||
|
:class:`types.FrameType`. Calculate them directly from the caught exception
|
||||||
|
without calling :func:`sys.exc_info`.
|
Loading…
Add table
Add a link
Reference in a new issue