MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / ConsoleWriter

Class ConsoleWriter

pydevconsole.py:487–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485
486
487class ConsoleWriter(InteractiveInterpreter):
488 skip = 0
489
490 def __init__(self, locals=None):
491 InteractiveInterpreter.__init__(self, locals)
492
493 def write(self, data):
494 # if (data.find("global_vars") == -1 and data.find("pydevd") == -1):
495 if self.skip > 0:
496 self.skip -= 1
497 else:
498 if data == "Traceback (most recent call last):\n":
499 self.skip = 1
500 sys.stderr.write(data)
501
502 def showsyntaxerror(self, filename=None):
503 """Display the syntax error that just occurred."""
504 # Override for avoid using sys.excepthook PY-12600
505 type, value, tb = sys.exc_info()
506 sys.last_type = type
507 sys.last_value = value
508 sys.last_traceback = tb
509 if filename and type is SyntaxError:
510 # Work hard to stuff the correct filename in the exception
511 try:
512 msg, (dummy_filename, lineno, offset, line) = value.args
513 except ValueError:
514 # Not the format we expect; leave it alone
515 pass
516 else:
517 # Stuff in the right filename
518 value = SyntaxError(msg, (filename, lineno, offset, line))
519 sys.last_value = value
520 list = traceback.format_exception_only(type, value)
521 sys.stderr.write("".join(list))
522
523 def showtraceback(self, *args, **kwargs):
524 """Display the exception that just occurred."""
525 # Override for avoid using sys.excepthook PY-12600
526 try:
527 type, value, tb = sys.exc_info()
528 sys.last_type = type
529 sys.last_value = value
530 sys.last_traceback = tb
531 tblist = traceback.extract_tb(tb)
532 del tblist[:1]
533 lines = traceback.format_list(tblist)
534 if lines:
535 lines.insert(0, "Traceback (most recent call last):\n")
536 lines.extend(traceback.format_exception_only(type, value))
537 finally:
538 tblist = tb = None
539 sys.stderr.write("".join(lines))
540
541
542def console_exec(thread_id, frame_id, expression, dbg):

Callers 1

console_execFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected