summaryrefslogtreecommitdiffstats
path: root/Python/modsupport.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-09 17:47:20 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-09 17:47:20 (GMT)
commit970a0a20b881962a950946cbc43e1941827a1e87 (patch)
tree2e312405bf094ae08231a8da943f18ecc0683243 /Python/modsupport.c
parent6da5bfad0f8d22361c8d7b45c1fd26789dd0635c (diff)
downloadcpython-970a0a20b881962a950946cbc43e1941827a1e87.zip
cpython-970a0a20b881962a950946cbc43e1941827a1e87.tar.gz
cpython-970a0a20b881962a950946cbc43e1941827a1e87.tar.bz2
api version checking
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r--Python/modsupport.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 9c5dbf9..9367684 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -33,20 +33,32 @@ typedef extended va_double;
typedef double va_double;
#endif
-/* initmodule3() has two additional parameters:
- - doc is the documentation string;
- - passthrough is passed as self to functions defined in the module.
+/* initmodule4() parameters:
+ - name is the module name
+ - methods is the list of top-level functions
+ - doc is the documentation string
+ - passthrough is passed as self to functions defined in the module
+ - api_version is the value of PYTHON_API_VERSION at the time the
+ module was compiled
*/
+static char api_version_warning[] =
+"WARNING: Python C API version mismatch for module %s:\n\
+ This Python has API version %d, module %s has version %s.\n";
+
object *
-initmodule3(name, methods, doc, passthrough)
+initmodule4(name, methods, doc, passthrough, module_api_version)
char *name;
struct methodlist *methods;
char *doc;
object *passthrough;
+ int module_api_version;
{
object *m, *d, *v;
struct methodlist *ml;
+ if (module_api_version != PYTHON_API_VERSION)
+ fprintf(stderr, api_version_warning,
+ name, PYTHON_API_VERSION, name, module_api_version);
if ((m = add_module(name)) == NULL) {
fprintf(stderr, "initializing module: %s\n", name);
fatal("can't create a module");
@@ -69,16 +81,6 @@ initmodule3(name, methods, doc, passthrough)
return m;
}
-/* The standard initmodule() passes NULL for 'self' */
-
-object *
-initmodule(name, methods)
- char *name;
- struct methodlist *methods;
-{
- return initmodule3(name, methods, (char *)NULL, (object *)NULL);
-}
-
/* Helper for mkvalue() to scan the length of a format */