]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105873: Make `_xxsubinterpreters` use exception type name in shared exception...
authorRadislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Sat, 8 Jul 2023 08:44:50 +0000 (11:44 +0300)
committerGitHub <noreply@github.com>
Sat, 8 Jul 2023 08:44:50 +0000 (08:44 +0000)
Lib/test/test__xxsubinterpreters.py
Lib/test/test_importlib/test_util.py
Modules/_xxsubinterpretersmodule.c

index 1ee18774d1720960c6da44b7d6c017961d418c38..ac2280eb7090e9afb5129d96c5b7c0e790e30742 100644 (file)
@@ -731,10 +731,10 @@ class RunStringTests(TestBase):
             yield
         if msg is None:
             self.assertEqual(str(caught.exception).split(':')[0],
-                             str(exctype))
+                             exctype.__name__)
         else:
             self.assertEqual(str(caught.exception),
-                             "{}: {}".format(exctype, msg))
+                             "{}: {}".format(exctype.__name__, msg))
 
     def test_invalid_syntax(self):
         with self.assert_run_failed(SyntaxError):
index e967adc9451c8137e3244394b5c5a901f5f64ee5..5da72a21f586ee7ac4b531ecadd0e2043dde74f3 100644 (file)
@@ -655,7 +655,7 @@ class MagicNumberTests(unittest.TestCase):
 @unittest.skipIf(_interpreters is None, 'subinterpreters required')
 class IncompatibleExtensionModuleRestrictionsTests(unittest.TestCase):
 
-    ERROR = re.compile("^<class 'ImportError'>: module (.*) does not support loading in subinterpreters")
+    ERROR = re.compile("^ImportError: module (.*) does not support loading in subinterpreters")
 
     def run_with_own_gil(self, script):
         interpid = _interpreters.create(isolated=True)
index 40dea170fd1f8b4e4ad75b423eff4e588d2cb19b..d2e0593872c5f0befd29dc2667a6de8d06c4c3b1 100644 (file)
@@ -273,7 +273,7 @@ _sharedexception_bind(PyObject *exc, _sharedexception *sharedexc)
     assert(exc != NULL);
     const char *failure = NULL;
 
-    PyObject *nameobj = PyUnicode_FromFormat("%S", Py_TYPE(exc));
+    PyObject *nameobj = PyUnicode_FromString(Py_TYPE(exc)->tp_name);
     if (nameobj == NULL) {
         failure = "unable to format exception type name";
         goto error;