@@ -60,6 +60,7 @@ def raise_catch(self, exc, excname):
6060 self .assertEqual (buf1 , buf2 )
6161 self .assertEqual (exc .__name__ , excname )
6262
63+ @support .thread_unsafe ("TESTFN" )
6364 def testRaising (self ):
6465 self .raise_catch (AttributeError , "AttributeError" )
6566 self .assertRaises (AttributeError , getattr , sys , "undefined_attribute" )
@@ -1361,6 +1362,7 @@ def test_unicode_error_str_does_not_crash(self):
13611362 self .assertIsInstance (str (exc ), str )
13621363
13631364 @no_tracing
1365+ @support .thread_unsafe ("captures stderr" )
13641366 def test_badisinstance (self ):
13651367 # Bug #2542: if issubclass(e, MyException) raises an exception,
13661368 # it should be ignored
@@ -1484,6 +1486,7 @@ def test_recursion_normalizing_infinite_exception(self):
14841486 self .assertIn (b'Done.' , out )
14851487
14861488
1489+ @support .thread_unsafe ("uses sys.setrecursionlimit" )
14871490 def test_recursion_in_except_handler (self ):
14881491
14891492 def set_relative_recursion_limit (n ):
@@ -1619,6 +1622,7 @@ class C(object):
16191622
16201623 @cpython_only
16211624 @unittest .skipIf (_testcapi is None , "requires _testcapi" )
1625+ @support .thread_unsafe ("gc_collect()" )
16221626 def test_memory_error_cleanup (self ):
16231627 # Issue #5437: preallocated MemoryError instances should not keep
16241628 # traceback objects alive.
@@ -1668,6 +1672,7 @@ def test_errno_ENOTDIR(self):
16681672 os .listdir (__file__ )
16691673 self .assertEqual (cm .exception .errno , errno .ENOTDIR , cm .exception )
16701674
1675+ @support .thread_unsafe ("uses catch_unraisable_exception" )
16711676 def test_unraisable (self ):
16721677 # Issue #22836: PyErr_WriteUnraisable() should give sensible reports
16731678 class BrokenDel :
@@ -1687,6 +1692,7 @@ def __del__(self):
16871692 f"deallocator { obj_repr } " )
16881693 self .assertIsNotNone (cm .unraisable .exc_traceback )
16891694
1695+ @support .thread_unsafe ("captures stderr" )
16901696 def test_unhandled (self ):
16911697 # Check for sensible reporting of unhandled exceptions
16921698 for exc_type in (ValueError , BrokenStrException ):
@@ -1786,6 +1792,7 @@ def g():
17861792 next (i )
17871793
17881794 @unittest .skipUnless (__debug__ , "Won't work if __debug__ is False" )
1795+ @support .thread_unsafe ("modifies global AssertionError" )
17891796 def test_assert_shadowing (self ):
17901797 # Shadowing AssertionError would cause the assert statement to
17911798 # misbehave.
@@ -1877,6 +1884,7 @@ def test_name_error_has_name(self):
18771884 except NameError as exc :
18781885 self .assertEqual ("bluch" , exc .name )
18791886
1887+ @support .thread_unsafe ("captures stderr" )
18801888 def test_issue45826 (self ):
18811889 # regression test for bpo-45826
18821890 def f ():
@@ -1893,6 +1901,7 @@ def f():
18931901
18941902 self .assertIn ("aab" , err .getvalue ())
18951903
1904+ @support .thread_unsafe ("captures stderr" )
18961905 def test_issue45826_focused (self ):
18971906 def f ():
18981907 try :
@@ -2295,6 +2304,7 @@ class MySyntaxError(SyntaxError):
22952304 ^^^^^
22962305""" , err .getvalue ())
22972306
2307+ @support .thread_unsafe ("TESTFN" )
22982308 def test_encodings (self ):
22992309 self .addCleanup (unlink , TESTFN )
23002310 source = (
0 commit comments