Skip to content

Commit

Permalink
BUG: Python3: Fix ctkPythonConsoleCompleter to look up "__code__" ins…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Apr 15, 2019
1 parent 83cbf7e commit e06346e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Libs/Scripting/Python/Widgets/ctkPythonConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ int ctkPythonConsoleCompleter::parameterCountUserDefinedFunction(const QString&
PyObject* pFunction = this->PythonManager.pythonModule(pythonFunctionName);
if (PyCallable_Check(pFunction))
{
#if PY_MAJOR_VERSION >= 3
PyObject* fc = PyObject_GetAttrString(pFunction, "__code__");
#else
PyObject* fc = PyObject_GetAttrString(pFunction, "func_code");
#endif
if (fc)
{
PyObject* ac = PyObject_GetAttrString(fc, "co_argcount");
Expand All @@ -228,7 +232,11 @@ int ctkPythonConsoleCompleter::parameterCountUserDefinedClassFunction(const QStr
PyObject* pFunction = this->PythonManager.pythonObject(pythonFunctionName);
if (PyCallable_Check(pFunction))
{
#if PY_MAJOR_VERSION >= 3
PyObject* fc = PyObject_GetAttrString(pFunction, "__code__");
#else
PyObject* fc = PyObject_GetAttrString(pFunction, "func_code");
#endif
if (fc)
{
PyObject* ac = PyObject_GetAttrString(fc, "co_argcount");
Expand Down

0 comments on commit e06346e

Please sign in to comment.