New submission from Xinmeng Xia <xi...@smail.nju.edu.cn>:

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

----------
components: Library (Lib)
messages: 406445
nosy: xxm
priority: normal
severity: normal
status: open
title: unittest.assertRaisesRegex is broken in Python 3.11 and leading to 
crashing if tested regex does not match name.
type: crash
versions: Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45826>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to