Пример #1
0
/**
 * Called from Python with the codeObject and line number of the currently executing line
 * @param codeObject A pointer to the code object whose line is executing
 * @param lineNo The line number that the code is currently executing, note that
 * this will be relative to the top of the code that was executed
 */
void PythonScript::lineNumberChanged(PyObject *codeObject, int lineNo)
{
    if(codeObject == m_CodeFileObject)
    {
        sendLineChangeSignal(getRealLineNo(lineNo), false);
    }
}
Пример #2
0
/**
 * Form a traceback
 * @param msg The reference to the textstream to accumulate the message
 * @param traceback A traceback object
 * @param root If true then this is the root of the traceback
 */
void PythonScript::tracebackToMsg(QTextStream &msgStream,
                                  PyTracebackObject *traceback, bool root) {
  if (traceback == nullptr)
    return;
  msgStream << "\n  ";
  if (root)
    msgStream << "at";
  else
    msgStream << "caused by";

  int lineno = traceback->tb_lineno;
  QString filename =
      QString::fromAscii(TO_CSTRING(traceback->tb_frame->f_code->co_filename));
  if (filename == identifier().c_str()) {
    lineno = getRealLineNo(lineno);
    sendLineChangeSignal(lineno, true);
  }

  msgStream << " line " << lineno << " in \'" << filename << "\'";
  tracebackToMsg(msgStream, traceback->tb_next, false);
}