Skip to content

Commit 69a39bd

Browse files
authored
gh-105873: Make _xxsubinterpreters use exception type name in shared exception (#105874)
1 parent 2ef1dc3 commit 69a39bd

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Lib/test/test__xxsubinterpreters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,10 +731,10 @@ def assert_run_failed(self, exctype, msg=None):
731731
yield
732732
if msg is None:
733733
self.assertEqual(str(caught.exception).split(':')[0],
734-
str(exctype))
734+
exctype.__name__)
735735
else:
736736
self.assertEqual(str(caught.exception),
737-
"{}: {}".format(exctype, msg))
737+
"{}: {}".format(exctype.__name__, msg))
738738

739739
def test_invalid_syntax(self):
740740
with self.assert_run_failed(SyntaxError):

Lib/test/test_importlib/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ def test_magic_number(self):
655655
@unittest.skipIf(_interpreters is None, 'subinterpreters required')
656656
class IncompatibleExtensionModuleRestrictionsTests(unittest.TestCase):
657657

658-
ERROR = re.compile("^<class 'ImportError'>: module (.*) does not support loading in subinterpreters")
658+
ERROR = re.compile("^ImportError: module (.*) does not support loading in subinterpreters")
659659

660660
def run_with_own_gil(self, script):
661661
interpid = _interpreters.create(isolated=True)

Modules/_xxsubinterpretersmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ _sharedexception_bind(PyObject *exc, _sharedexception *sharedexc)
273273
assert(exc != NULL);
274274
const char *failure = NULL;
275275

276-
PyObject *nameobj = PyUnicode_FromFormat("%S", Py_TYPE(exc));
276+
PyObject *nameobj = PyUnicode_FromString(Py_TYPE(exc)->tp_name);
277277
if (nameobj == NULL) {
278278
failure = "unable to format exception type name";
279279
goto error;

0 commit comments

Comments
 (0)