]> granicus.if.org Git - python/commitdiff
bug [ 1232768 ] Mistakes in online docs under "5.3 Pure Embedding"
authorGeorg Brandl <georg@python.org>
Tue, 12 Jul 2005 13:17:59 +0000 (13:17 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 12 Jul 2005 13:17:59 +0000 (13:17 +0000)
Doc/ext/run-func.c

index b5be5c6bf4ff8f14a0042cbaff33a62b96defb95..ff742907955327017ce1f3b2be074a1be848b41f 100644 (file)
@@ -20,11 +20,8 @@ main(int argc, char *argv[])
     Py_DECREF(pName);
 
     if (pModule != NULL) {
-        pDict = PyModule_GetDict(pModule);
-        /* pDict is a borrowed reference */
-
-        pFunc = PyDict_GetItemString(pDict, argv[2]);
-        /* pFun: Borrowed reference */
+        pFunc = PyDict_GetItemString(pModule, argv[2]);
+        /* pFunc is a new reference */
 
         if (pFunc && PyCallable_Check(pFunc)) {
             pArgs = PyTuple_New(argc - 3);
@@ -46,18 +43,19 @@ main(int argc, char *argv[])
                 Py_DECREF(pValue);
             }
             else {
+                Py_DECREF(pFunc);
                 Py_DECREF(pModule);
                 PyErr_Print();
                 fprintf(stderr,"Call failed\n");
                 return 1;
             }
-            /* pDict and pFunc are borrowed and must not be Py_DECREF-ed */
         }
         else {
             if (PyErr_Occurred())
                 PyErr_Print();
             fprintf(stderr, "Cannot find function \"%s\"\n", argv[2]);
         }
+        Py_XDECREF(pFunc);
         Py_DECREF(pModule);
     }
     else {