* Store the line into the internal buffer and compile the total buffer. * In case it is a complete Python command the buffer is emptied. */
| 373 | * In case it is a complete Python command the buffer is emptied. |
| 374 | */ |
| 375 | bool InteractiveInterpreter::push(const char* line) |
| 376 | { |
| 377 | d->buffer.append(QString::fromUtf8(line)); |
| 378 | QString source = d->buffer.join(QLatin1String("\n")); |
| 379 | try { |
| 380 | bool more = runSource(source.toUtf8()); |
| 381 | if (!more) { |
| 382 | d->buffer.clear(); |
| 383 | } |
| 384 | return more; |
| 385 | } |
| 386 | catch (const Base::SystemExitException&) { |
| 387 | d->buffer.clear(); |
| 388 | throw; |
| 389 | } |
| 390 | catch (...) { |
| 391 | // indication of unhandled exception |
| 392 | d->buffer.clear(); |
| 393 | if (PyErr_Occurred()) { |
| 394 | PyErr_Print(); |
| 395 | } |
| 396 | throw; |
| 397 | } |
| 398 | |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | bool InteractiveInterpreter::hasPendingInput() const |
| 403 | { |