@@ -33,20 +33,32 @@ typedef extended va_double;
33
33
typedef double va_double ;
34
34
#endif
35
35
36
- /* initmodule3() has two additional parameters:
37
- - doc is the documentation string;
38
- - passthrough is passed as self to functions defined in the module.
36
+ /* initmodule4() parameters:
37
+ - name is the module name
38
+ - methods is the list of top-level functions
39
+ - doc is the documentation string
40
+ - passthrough is passed as self to functions defined in the module
41
+ - api_version is the value of PYTHON_API_VERSION at the time the
42
+ module was compiled
39
43
*/
40
44
45
+ static char api_version_warning [] =
46
+ "WARNING: Python C API version mismatch for module %s:\n\
47
+ This Python has API version %d, module %s has version %s.\n" ;
48
+
41
49
object *
42
- initmodule3 (name , methods , doc , passthrough )
50
+ initmodule4 (name , methods , doc , passthrough , module_api_version )
43
51
char * name ;
44
52
struct methodlist * methods ;
45
53
char * doc ;
46
54
object * passthrough ;
55
+ int module_api_version ;
47
56
{
48
57
object * m , * d , * v ;
49
58
struct methodlist * ml ;
59
+ if (module_api_version != PYTHON_API_VERSION )
60
+ fprintf (stderr , api_version_warning ,
61
+ name , PYTHON_API_VERSION , name , module_api_version );
50
62
if ((m = add_module (name )) == NULL ) {
51
63
fprintf (stderr , "initializing module: %s\n" , name );
52
64
fatal ("can't create a module" );
@@ -69,16 +81,6 @@ initmodule3(name, methods, doc, passthrough)
69
81
return m ;
70
82
}
71
83
72
- /* The standard initmodule() passes NULL for 'self' */
73
-
74
- object *
75
- initmodule (name , methods )
76
- char * name ;
77
- struct methodlist * methods ;
78
- {
79
- return initmodule3 (name , methods , (char * )NULL , (object * )NULL );
80
- }
81
-
82
84
83
85
/* Helper for mkvalue() to scan the length of a format */
84
86
0 commit comments