cpython: eb47af6e9e22 (original) (raw)
Mercurial > cpython
changeset 74471:eb47af6e9e22 3.2
Test running of code in a sub-interpreter (prelude to issue #6531). [#6531]
Antoine Pitrou solipsis@pitrou.net | |
---|---|
date | Wed, 18 Jan 2012 00:21:11 +0100 |
parents | f715c4a5a107 |
children | a108818aaa0d eed73b16e71f |
files | Lib/test/test_capi.py Modules/_testcapimodule.c |
diffstat | 2 files changed, 44 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_capi.py 17 Modules/_testcapimodule.c 27 |
line wrap: on
line diff
--- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -3,6 +3,7 @@ from future import with_statement import os +import pickle import random import subprocess import sys @@ -137,6 +138,22 @@ class TestPendingCalls(unittest.TestCase self.pendingcalls_submit(l, n) self.pendingcalls_wait(l, n)
- def test_subinterps(self):
# XXX this test leaks in refleak runs[](#l1.16)
import builtins[](#l1.17)
r, w = os.pipe()[](#l1.18)
code = """if 1:[](#l1.19)
import sys, builtins, pickle[](#l1.20)
with open({:d}, "wb") as f:[](#l1.21)
pickle.dump(id(sys.modules), f)[](#l1.22)
pickle.dump(id(builtins), f)[](#l1.23)
""".format(w)[](#l1.24)
with open(r, "rb") as f:[](#l1.25)
ret = _testcapi.run_in_subinterp(code)[](#l1.26)
self.assertEqual(ret, 0)[](#l1.27)
self.assertNotEqual(pickle.load(f), id(sys.modules))[](#l1.28)
self.assertNotEqual(pickle.load(f), id(builtins))[](#l1.29)
Bug #6012
class Test6012(unittest.TestCase): def test(self):
--- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2300,6 +2300,32 @@ crash_no_current_thread(PyObject self) return NULL; } +/ To run some code in a sub-interpreter. */ +static PyObject * +run_in_subinterp(PyObject *self, PyObject *args) +{
+} + + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS}, @@ -2385,6 +2411,7 @@ static PyMethodDef TestMethods[] = { {"make_memoryview_from_NULL_pointer", (PyCFunction)make_memoryview_from_NULL_pointer, METH_NOARGS}, {"crash_no_current_thread", (PyCFunction)crash_no_current_thread, METH_NOARGS},