This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xxm
Recipients xxm
Date 2021-11-17.02:50:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1637117458.73.0.114142270952.issue45826@roundup.psfhosted.org>
In-reply-to
Content
In Python 3.11, unittest.assertRaisesRegex is broken and leading to crashing if tested regex does not match name. See the following example:

test.py
=========================================
import unittest

class uTest(unittest.TestCase):
	pass

uTest = uTest()

with uTest.assertRaisesRegex(Exception, 'aaa'):
     aab
=========================================


Output in Python3.9.2, 3.10:
--------------------------------------
NameError: name 'aab' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xxm/Desktop/test.py", line 29, in <module>
    aab
  File "/usr/local/python310/lib/python3.10/unittest/case.py", line 239, in __exit__
    self._raiseFailure('"{}" does not match "{}"'.format(
  File "/usr/local/python310/lib/python3.10/unittest/case.py", line 163, in _raiseFailure
    raise self.test_case.failureException(msg)
AssertionError: "aaa" does not match "name 'aab' is not defined
--------------------------------------------------

Actual output in Python3.11.0a1,Python3.11.0a2:
Segmentation fault (core dumped)

System: Ubuntu 16.04
History
Date User Action Args
2021-11-17 02:50:58xxmsetrecipients: + xxm
2021-11-17 02:50:58xxmsetmessageid: <1637117458.73.0.114142270952.issue45826@roundup.psfhosted.org>
2021-11-17 02:50:58xxmlinkissue45826 messages
2021-11-17 02:50:58xxmcreate