Skip to content

Commit 9c7456d

Browse files
committed
Fix PyObject leak in get_conv_table_from_main
1 parent e6a395c commit 9c7456d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

c++/cpp2py/py_converter.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ namespace cpp2py {
5454
// Fetch the pointer to the converter table from __main__
5555
inline std::shared_ptr<conv_table_t> get_conv_table_from_main() {
5656
// Fetch __main__ module
57-
pyref mod = PyImport_GetModule(PyUnicode_FromString("__main__"));
57+
pyref str_main = PyUnicode_FromString("__main__");
58+
pyref mod = PyImport_GetModule(str_main);
5859
if (mod == NULL) {
5960
PyErr_SetString(PyExc_RuntimeError, "Severe internal error : can not load __main__");
6061
throw std::runtime_error("Severe internal error : can not load __main__");

0 commit comments

Comments
 (0)