Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9abfa90

Browse files
committed
bug [ 1232768 ] Mistakes in online docs under "5.3 Pure Embedding"
1 parent 0edc7a0 commit 9abfa90

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

Doc/ext/run-func.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ main(int argc, char *argv[])
2020
Py_DECREF(pName);
2121

2222
if (pModule != NULL) {
23-
pDict = PyModule_GetDict(pModule);
24-
/* pDict is a borrowed reference */
25-
26-
pFunc = PyDict_GetItemString(pDict, argv[2]);
27-
/* pFun: Borrowed reference */
23+
pFunc = PyDict_GetItemString(pModule, argv[2]);
24+
/* pFunc is a new reference */
2825

2926
if (pFunc && PyCallable_Check(pFunc)) {
3027
pArgs = PyTuple_New(argc - 3);
@@ -46,18 +43,19 @@ main(int argc, char *argv[])
4643
Py_DECREF(pValue);
4744
}
4845
else {
46+
Py_DECREF(pFunc);
4947
Py_DECREF(pModule);
5048
PyErr_Print();
5149
fprintf(stderr,"Call failed\n");
5250
return 1;
5351
}
54-
/* pDict and pFunc are borrowed and must not be Py_DECREF-ed */
5552
}
5653
else {
5754
if (PyErr_Occurred())
5855
PyErr_Print();
5956
fprintf(stderr, "Cannot find function \"%s\"\n", argv[2]);
6057
}
58+
Py_XDECREF(pFunc);
6159
Py_DECREF(pModule);
6260
}
6361
else {

0 commit comments

Comments
 (0)