gh-76785: Raise InterpreterError, Not RuntimeError (gh-117489)

I had meant to switch everything to InterpreterError when I added it a while back.  At the time I missed a few key spots.

As part of this, I've added print-the-exception to _PyXI_InitTypes() and fixed an error case in `_PyStaticType_InitBuiltin().
This commit is contained in:
Eric Snow 2024-04-03 10:58:39 -06:00 committed by GitHub
parent 7ecd55d604
commit 976bcb2379
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 40 additions and 23 deletions

View file

@ -364,11 +364,11 @@ class TestInterpreterClose(TestBase):
def test_main(self):
main, = interpreters.list_all()
with self.assertRaises(RuntimeError):
with self.assertRaises(interpreters.InterpreterError):
main.close()
def f():
with self.assertRaises(RuntimeError):
with self.assertRaises(interpreters.InterpreterError):
main.close()
t = threading.Thread(target=f)
@ -389,7 +389,7 @@ class TestInterpreterClose(TestBase):
interp = interpreters.Interpreter({interp.id})
try:
interp.close()
except RuntimeError:
except interpreters.InterpreterError:
print('failed')
"""))
self.assertEqual(out.strip(), 'failed')
@ -424,7 +424,7 @@ class TestInterpreterClose(TestBase):
main, = interpreters.list_all()
interp = interpreters.create()
with _running(interp):
with self.assertRaises(RuntimeError):
with self.assertRaises(interpreters.InterpreterError):
interp.close()
self.assertTrue(interp.is_running())
@ -1103,7 +1103,7 @@ class LowLevelTests(TestBase):
self.assert_ns_equal(config, default)
with self.subTest('arg: \'empty\''):
with self.assertRaises(RuntimeError):
with self.assertRaises(interpreters.InterpreterError):
# The "empty" config isn't viable on its own.
_interpreters.create('empty')