From d1e329048a4dc6bc1987a77946780bc7720daa96 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Sat, 14 Oct 2017 12:31:36 +0200 Subject: [PATCH] Do not decref PySys_GetObject return values (Fixes #84) The function PySys_GetObject() returns a borrowed reference only, so we must incref/decref the value accordingly, and not take ownership of the returned value. https://docs.python.org/3/c-api/sys.html#c.PySys_GetObject --- src/qpython_priv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qpython_priv.cpp b/src/qpython_priv.cpp index e569336..31eca26 100644 --- a/src/qpython_priv.cpp +++ b/src/qpython_priv.cpp @@ -652,7 +652,7 @@ QPythonPriv::instance() QString QPythonPriv::importFromQRC(const char *module, const QString &filename) { - PyObjectRef sys_modules(PySys_GetObject((char *)"modules"), true); + PyObjectRef sys_modules(PySys_GetObject((char *)"modules")); if (!PyMapping_Check(sys_modules.borrow())) { return QString("sys.modules is not a mapping object"); }