summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadislav Chugunov <52372310+chgnrdv@users.noreply.github.com>2023-07-08 08:44:50 (GMT)
committerGitHub <noreply@github.com>2023-07-08 08:44:50 (GMT)
commit69a39bd9ad52241ca0e9a1926b4536c73017d067 (patch)
treed69f7a6d07b13127b2d8e01fd9af6ed7abd486a2
parent2ef1dc37f02b08536b677dd23ec51541a60effd7 (diff)
downloadcpython-69a39bd9ad52241ca0e9a1926b4536c73017d067.zip
cpython-69a39bd9ad52241ca0e9a1926b4536c73017d067.tar.gz
cpython-69a39bd9ad52241ca0e9a1926b4536c73017d067.tar.bz2
gh-105873: Make `_xxsubinterpreters` use exception type name in shared exception (#105874)
-rw-r--r--Lib/test/test__xxsubinterpreters.py4
-rw-r--r--Lib/test/test_importlib/test_util.py2
-rw-r--r--Modules/_xxsubinterpretersmodule.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test__xxsubinterpreters.py b/Lib/test/test__xxsubinterpreters.py
index 1ee1877..ac2280e 100644
--- a/Lib/test/test__xxsubinterpreters.py
+++ b/Lib/test/test__xxsubinterpreters.py
@@ -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):
diff --git a/Lib/test/test_importlib/test_util.py b/Lib/test/test_importlib/test_util.py
index e967adc..5da72a2 100644
--- a/Lib/test/test_importlib/test_util.py
+++ b/Lib/test/test_importlib/test_util.py
@@ -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)
diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
index 40dea17..d2e0593 100644
--- a/Modules/_xxsubinterpretersmodule.c
+++ b/Modules/_xxsubinterpretersmodule.c
@@ -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;