mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Slight reworking to make it more useful for debugging
Py_Initialize()/Py_Finalize() loop leaks. - allow an optional 3rd argument which is the loop count. -1 means infloop (the default). - Add a setting of Py_NoSiteFlag=1, but leave it commented out by default.
This commit is contained in:
parent
7d23b59e34
commit
0c63fe9b54
1 changed files with 12 additions and 5 deletions
|
@ -6,21 +6,28 @@
|
||||||
|
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int count = -1;
|
||||||
char *command;
|
char *command;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc < 2 || argc > 3) {
|
||||||
fprintf(stderr, "usage: loop <python-command>\n");
|
fprintf(stderr, "usage: loop <python-command> [count]\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
command = argv[1];
|
command = argv[1];
|
||||||
|
|
||||||
|
if (argc == 3) {
|
||||||
|
count = atoi(argv[2]);
|
||||||
|
}
|
||||||
|
|
||||||
Py_SetProgramName(argv[0]);
|
Py_SetProgramName(argv[0]);
|
||||||
|
|
||||||
while (1) {
|
/* uncomment this if you don't want to load site.py */
|
||||||
|
/* Py_NoSiteFlag = 1; */
|
||||||
|
|
||||||
|
while (count == -1 || --count >= 0 ) {
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
PyRun_SimpleString(command);
|
PyRun_SimpleString(command);
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
}
|
}
|
||||||
/*NOTREACHED*/
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue