Guido van Rossum | 3559d1f | 2001-01-10 17:11:51 +0000 | [diff] [blame] | 1 | /* Simple program that repeatedly calls Py_Initialize(), does something, and |
| 2 | then calls Py_Finalize(). This should help finding leaks related to |
| 3 | initialization. */ |
| 4 | |
| 5 | #include "Python.h" |
| 6 | |
| 7 | main(int argc, char **argv) |
| 8 | { |
| 9 | char *command; |
| 10 | |
| 11 | if (argc != 2) { |
| 12 | fprintf(stderr, "usage: loop <python-command>\n"); |
| 13 | exit(2); |
| 14 | } |
| 15 | |
| 16 | command = argv[1]; |
| 17 | |
| 18 | Py_SetProgramName(argv[0]); |
| 19 | |
| 20 | while (1) { |
| 21 | Py_Initialize(); |
| 22 | PyRun_SimpleString(command); |
| 23 | Py_Finalize(); |
| 24 | } |
| 25 | /*NOTREACHED*/ |
| 26 | } |