[Martin Sjögren] > I'm a bit curious about the memory handling of the Py_InitModule4... > > When adding methods, if PyCFunction_New fails, NULL is returned > without the module object being DECREF'd, and similarly, if the > PyDict_SetItemString fails, NULL is returned without neither module > object nor function object being DECREF'd. > > Is this a problem, or is this taken care of somewhere else? The first one is not a problem. The module 'm' is received from PyImport_AddModule(), which (in a comment in the source) emphasizes that the return value does not have its reference count incremented. Instead, the module is kept alive because it is stored in sys.modules. The second one should really DECREF v when PyDict_SetItemString() fails. Ditto for the docstring. I've added a low-priority bug report, because this is very unlikely to happen. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4