summaryrefslogtreecommitdiffstats
path: root/Demo/embed/loop.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-01-10 17:11:51 (GMT)
committerGuido van Rossum <guido@python.org>2001-01-10 17:11:51 (GMT)
commit3559d1f9b3f33b45de924f5d17dcea6ab949bb41 (patch)
treeaa46bef878d40f1ad03d2b7e78bd980e897fbbda /Demo/embed/loop.c
parent7339f4c72d2eaf9fef2416d3328207dcc655f578 (diff)
downloadcpython-3559d1f9b3f33b45de924f5d17dcea6ab949bb41.zip
cpython-3559d1f9b3f33b45de924f5d17dcea6ab949bb41.tar.gz
cpython-3559d1f9b3f33b45de924f5d17dcea6ab949bb41.tar.bz2
Add loop.c -- a test program for repeatedly calling Py_Initialize()
and Py_Finalize(). It seems to dump core right now...
Diffstat (limited to 'Demo/embed/loop.c')
-rw-r--r--Demo/embed/loop.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/Demo/embed/loop.c b/Demo/embed/loop.c
new file mode 100644
index 0000000..ca89cb7
--- /dev/null
+++ b/Demo/embed/loop.c
@@ -0,0 +1,26 @@
+/* Simple program that repeatedly calls Py_Initialize(), does something, and
+ then calls Py_Finalize(). This should help finding leaks related to
+ initialization. */
+
+#include "Python.h"
+
+main(int argc, char **argv)
+{
+ char *command;
+
+ if (argc != 2) {
+ fprintf(stderr, "usage: loop <python-command>\n");
+ exit(2);
+ }
+
+ command = argv[1];
+
+ Py_SetProgramName(argv[0]);
+
+ while (1) {
+ Py_Initialize();
+ PyRun_SimpleString(command);
+ Py_Finalize();
+ }
+ /*NOTREACHED*/
+}