Index: Lib/test/test_capi.py =================================================================== --- Lib/test/test_capi.py (Revision 60448) +++ Lib/test/test_capi.py (Arbeitskopie) @@ -2,11 +2,28 @@ # these are all functions _testcapi exports whose name begins with 'test_'. import sys +import os +import subprocess from test import test_support import _testcapi +def test_reinit(): + """Test multiple reinitialization + """ + base = os.path.dirname(sys.executable) + reinit = os.path.join(base, "test_reinit") + if not os.path.isfile(reinit): + return + p = subprocess.Popen(reinit, stdout = subprocess.PIPE, + stderr = subprocess.STDOUT) + if p.wait() != 0: + print p.stdout.read() + assert p.wait() == 0 + def test_main(): + test_reinit() + for name in dir(_testcapi): if name.startswith('test_'): test = getattr(_testcapi, name) Index: Makefile.pre.in =================================================================== --- Makefile.pre.in (Revision 60448) +++ Makefile.pre.in (Arbeitskopie) @@ -175,6 +175,7 @@ PYTHON= python$(EXE) BUILDPYTHON= python$(BUILDEXE) +TEST_REINIT= test_reinit$(EXE) # === Definitions added by makesetup === @@ -343,7 +344,7 @@ # Default target all: build_all -build_all: $(BUILDPYTHON) oldsharedmods sharedmods +build_all: $(BUILDPYTHON) $(TEST_REINIT) oldsharedmods sharedmods # Build the interpreter $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) @@ -351,6 +352,12 @@ Modules/python.o \ $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) +$(TEST_REINIT): Modules/test_reinit.o $(LIBRARY) $(LDLIBRARY) + $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \ + Modules/test_reinit.o \ + $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) + + platform: $(BUILDPYTHON) $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform @@ -481,6 +488,8 @@ Modules/python.o: $(srcdir)/Modules/python.c $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c +Modules/test_reinit.o: $(srcdir)/Modules/test_reinit.c + $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/test_reinit.c $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT) -@$(INSTALL) -d Include Index: Modules/test_reinit.c =================================================================== --- Modules/test_reinit.c (Revision 0) +++ Modules/test_reinit.c (Revision 0) @@ -0,0 +1,23 @@ +/* Test multiple reinitializations of the interpreter + */ + +#include "Python.h" +#define ROUNDS 10 +#undef CAUSE_SEGFAULT +#undef VERBOSE + +int main(void) { + int i; +#ifdef VERBOSE + Py_VerboseFlag++; +#endif + for (i=0; i < ROUNDS; i++) { + printf("round %d\n", i+1); + Py_Initialize(); +#ifdef CAUSE_SEGFAULT + Py_DECREF(PySys_GetObject("float_info")); +#endif + Py_Finalize(); + } + return 0; +} Eigenschaftsänderungen: Modules/test_reinit.c ___________________________________________________________________ Name: svn:keywords + Id Name: svn:eol-style + native