Andrew Svetlov | 6b2cbeb | 2012-12-14 17:04:59 +0200 | [diff] [blame] | 1 | /* |
| 2 | * C extensions module to test importing multiple modules from one compiled |
| 3 | * file (issue16421). This file defines 3 modules (_testimportmodule, |
| 4 | * foo, bar), only the first one is called the same as the compiled file. |
| 5 | */ |
| 6 | #include<Python.h> |
| 7 | |
| 8 | static struct PyModuleDef _testimportmultiple = { |
| 9 | PyModuleDef_HEAD_INIT, |
| 10 | "_testimportmultiple", |
| 11 | "_testimportmultiple doc", |
| 12 | -1, |
| 13 | NULL, |
| 14 | NULL, |
| 15 | NULL, |
| 16 | NULL, |
| 17 | NULL |
| 18 | }; |
| 19 | |
Andrew Svetlov | 1a71475 | 2012-12-15 18:16:47 +0200 | [diff] [blame] | 20 | PyMODINIT_FUNC PyInit__testimportmultiple(void) |
Andrew Svetlov | 6b2cbeb | 2012-12-14 17:04:59 +0200 | [diff] [blame] | 21 | { |
| 22 | return PyModule_Create(&_testimportmultiple); |
| 23 | } |
| 24 | |
| 25 | static struct PyModuleDef _foomodule = { |
| 26 | PyModuleDef_HEAD_INIT, |
Andrew Svetlov | ef9a43b | 2012-12-15 17:22:59 +0200 | [diff] [blame] | 27 | "_testimportmultiple_foo", |
| 28 | "_testimportmultiple_foo doc", |
Andrew Svetlov | 6b2cbeb | 2012-12-14 17:04:59 +0200 | [diff] [blame] | 29 | -1, |
| 30 | NULL, |
| 31 | NULL, |
| 32 | NULL, |
| 33 | NULL, |
| 34 | NULL |
| 35 | }; |
| 36 | |
Andrew Svetlov | 1a71475 | 2012-12-15 18:16:47 +0200 | [diff] [blame] | 37 | PyMODINIT_FUNC PyInit__testimportmultiple_foo(void) |
Andrew Svetlov | 6b2cbeb | 2012-12-14 17:04:59 +0200 | [diff] [blame] | 38 | { |
| 39 | return PyModule_Create(&_foomodule); |
| 40 | } |
| 41 | |
| 42 | static struct PyModuleDef _barmodule = { |
| 43 | PyModuleDef_HEAD_INIT, |
Andrew Svetlov | ef9a43b | 2012-12-15 17:22:59 +0200 | [diff] [blame] | 44 | "_testimportmultiple_bar", |
| 45 | "_testimportmultiple_bar doc", |
Andrew Svetlov | 6b2cbeb | 2012-12-14 17:04:59 +0200 | [diff] [blame] | 46 | -1, |
| 47 | NULL, |
| 48 | NULL, |
| 49 | NULL, |
| 50 | NULL, |
| 51 | NULL |
| 52 | }; |
| 53 | |
Andrew Svetlov | 1a71475 | 2012-12-15 18:16:47 +0200 | [diff] [blame] | 54 | PyMODINIT_FUNC PyInit__testimportmultiple_bar(void){ |
Andrew Svetlov | 6b2cbeb | 2012-12-14 17:04:59 +0200 | [diff] [blame] | 55 | return PyModule_Create(&_barmodule); |
| 56 | } |
| 57 | |