@@ -33,20 +33,32 @@ typedef extended va_double;
3333typedef double va_double ;
3434#endif
3535
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
3943*/
4044
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+
4149object *
42- initmodule3 (name , methods , doc , passthrough )
50+ initmodule4 (name , methods , doc , passthrough , module_api_version )
4351 char * name ;
4452 struct methodlist * methods ;
4553 char * doc ;
4654 object * passthrough ;
55+ int module_api_version ;
4756{
4857 object * m , * d , * v ;
4958 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 );
5062 if ((m = add_module (name )) == NULL ) {
5163 fprintf (stderr , "initializing module: %s\n" , name );
5264 fatal ("can't create a module" );
@@ -69,16 +81,6 @@ initmodule3(name, methods, doc, passthrough)
6981 return m ;
7082}
7183
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-
8284
8385/* Helper for mkvalue() to scan the length of a format */
8486
0 commit comments