annotate Demo/embed/loop.c @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents fd25030223b0
children cc2f864bac9c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15797
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* Simple program that repeatedly calls Py_Initialize(), does something, and
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 then calls Py_Finalize(). This should help finding leaks related to
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 initialization. */
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #include "Python.h"
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 main(int argc, char **argv)
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
9 int count = -1;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
10 char *command;
15797
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
12 if (argc < 2 || argc > 3) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
13 fprintf(stderr, "usage: loop <python-command> [count]\n");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
14 exit(2);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
15 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
16 command = argv[1];
15797
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
18 if (argc == 3) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
19 count = atoi(argv[2]);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
20 }
15797
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
22 Py_SetProgramName(argv[0]);
15797
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
23
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
24 /* uncomment this if you don't want to load site.py */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
25 /* Py_NoSiteFlag = 1; */
16171
7ae6a09d4d02 Slight reworking to make it more useful for debugging
Barry Warsaw <barry@python.org>
parents: 15797
diff changeset
26
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
27 while (count == -1 || --count >= 0 ) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
28 Py_Initialize();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
29 PyRun_SimpleString(command);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
30 Py_Finalize();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
31 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 16171
diff changeset
32 return 0;
15797
edd19217b396 Add loop.c -- a test program for repeatedly calling Py_Initialize()
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 }