CTK icon indicating copy to clipboard operation
CTK copied to clipboard

Pythonshell error

Open softempire opened this issue 4 years ago • 2 comments

I'm using the PythonShell from CTK. And sometimes the pythonshell will do nothing after I run several Python statemnts bool ctkPythonConsolePrivate::push(const QString& code) { Q_ASSERT(this->PythonManager);

bool ret_value = false;

QString buffer = code; // The embedded python interpreter cannot handle DOS line-endings, see // http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1167922 buffer.remove('\r');

PyObject res = PyObject_CallMethod(this->InteractiveConsole, const_cast<char>("push"), const_cast<char*>("z"),

When I debug the code, res will always be nullptr

Does anyone know the issue? I'm running Python 3.7.1 on Windows.

softempire avatar Aug 15 '21 14:08 softempire

Do you have the problem after you type an incorrect command (e.g., typing a command that has a syntax error)?

lassoan avatar Aug 15 '21 14:08 lassoan

It's easy to reproduce the issue if the python statement contains string. For example, I want to load a file so I will call prj.load('full file path') Then the shell will be responsible.

But sometimes, the load method will succeed. Another thing I want to mention is if I run the load method from a py file (I mean using the run script file method), it always succeed

softempire avatar Aug 15 '21 14:08 softempire