# Raise SkipTest if subinterpreters not supported.
import_helper.import_module('_interpreters')
from concurrent import interpreters
+from concurrent.interpreters import InterpreterError
from .utils import TestBase
start.set()
support.gc_collect()
+ def test_create_interpreter_no_memory(self):
+ import _interpreters
+ _testcapi = import_helper.import_module("_testcapi")
+
+ with self.assertRaises(InterpreterError):
+ _testcapi.set_nomemory(0, 1)
+ _interpreters.create()
+
if __name__ == '__main__':
# Test needs to be a package, so we can do relative imports.
interpreters: disable PyGILState_Check(). */
runtime->gilstate.check_enabled = 0;
- PyInterpreterState *interp = PyInterpreterState_New();
+ // XXX Might new_interpreter() have been called without the GIL held?
+ PyThreadState *save_tstate = _PyThreadState_GET();
+ PyThreadState *tstate = NULL;
+ PyInterpreterState *interp;
+ status = _PyInterpreterState_New(save_tstate, &interp);
if (interp == NULL) {
- *tstate_p = NULL;
- return _PyStatus_OK();
+ goto error;
}
_PyInterpreterState_SetWhence(interp, whence);
interp->_ready = 1;
- // XXX Might new_interpreter() have been called without the GIL held?
- PyThreadState *save_tstate = _PyThreadState_GET();
- PyThreadState *tstate = NULL;
-
/* From this point until the init_interp_create_gil() call,
we must not do anything that requires that the GIL be held
(or otherwise exist). That applies whether or not the new
*tstate_p = NULL;
if (tstate != NULL) {
Py_EndInterpreter(tstate);
- } else {
+ } else if (interp != NULL) {
PyInterpreterState_Delete(interp);
}
if (save_tstate != NULL) {