]> granicus.if.org Git - python/commitdiff
Initialize __version__ to the correct version string regardless of
authorGuido van Rossum <guido@python.org>
Mon, 1 Dec 1997 15:57:40 +0000 (15:57 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 1 Dec 1997 15:57:40 +0000 (15:57 +0000)
what RCS checkout options are used.  Problem first diagnosed by Marc
Lemburg.

Modules/cPickle.c

index 6021a03da42bba656d7ac9bc28a1a2288744197a..1f8ed9dcff9e5d678d63daa7578a2b6adfa59693 100644 (file)
@@ -3881,10 +3881,21 @@ init_stuff(PyObject *module, PyObject *module_dict) {
 void
 initcPickle() {
     PyObject *m, *d, *v;
-    char *rev="$Revision$";
+    static char revbuf[] = "$Revision$";
+    char *rev = revbuf;
     PyObject *format_version;
     PyObject *compatible_formats;
 
+    /* Fix up the revision number */
+    if (rev[0] == '$') {
+        char *p = strchr(rev, ' ');
+        if (p) {
+            rev = p+1;
+            p = strrchr(rev, ' ');
+            if (p)
+                *p = '\0';
+        }
+    }
 
     /* Create the module and add the functions */
     m = Py_InitModule4("cPickle", cPickle_methods,
@@ -3896,8 +3907,8 @@ initcPickle() {
 
     /* Add some symbolic constants to the module */
     d = PyModule_GetDict(m);
-    PyDict_SetItemString(d,"__version__",
-                    v = PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));
+    v = PyString_FromString(rev);
+    PyDict_SetItemString(d,"__version__", v);
     Py_XDECREF(v);
 
 #ifdef FORMAT_1_3