self.id = _interpreters.create()
def test_signatures(self):
- # for method in ['exec', 'run_string', 'run_func']:
+ # See https://github.com/python/cpython/issues/126654
msg = "expected 'shared' to be a dict"
with self.assertRaisesRegex(TypeError, msg):
_interpreters.exec(self.id, 'a', 1)
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_func(self.id, lambda: None, shared=1)
+ def test_invalid_shared_encoding(self):
+ # See https://github.com/python/cpython/issues/127196
+ bad_shared = {"\uD82A": 0}
+ msg = 'surrogates not allowed'
+ with self.assertRaisesRegex(UnicodeEncodeError, msg):
+ _interpreters.exec(self.id, 'a', shared=bad_shared)
+ with self.assertRaisesRegex(UnicodeEncodeError, msg):
+ _interpreters.run_string(self.id, 'a', shared=bad_shared)
+ with self.assertRaisesRegex(UnicodeEncodeError, msg):
+ _interpreters.run_func(self.id, lambda: None, shared=bad_shared)
+
class RunStringTests(TestBase):
// Prep and switch interpreters.
if (_PyXI_Enter(&session, interp, shareables) < 0) {
- assert(!PyErr_Occurred());
+ if (PyErr_Occurred()) {
+ // If an error occured at this step, it means that interp
+ // was not prepared and switched.
+ return -1;
+ }
+ // Now, apply the error from another interpreter:
PyObject *excinfo = _PyXI_ApplyError(session.error);
if (excinfo != NULL) {
*p_excinfo = excinfo;