Skip to content

Commit

Permalink
Fix raw_input on debugger redirect. Fixes microsoft#490 (microsoft#816)
Browse files Browse the repository at this point in the history
* Fix raw_input on debugger redirect. Fixes microsoft#490

* Fix test.
  • Loading branch information
fabioz authored and karthiknadig committed Sep 18, 2018
1 parent e1353d7 commit d3d3345
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ def make_show_console_message(self, thread_id, frame):

def make_input_requested_message(self, started):
try:
return NetCommand(CMD_INPUT_REQUESTED, 0, started)
return NetCommand(CMD_INPUT_REQUESTED, 0, str(started))
except:
return self.make_error_message(0, get_exception_traceback_str())

Expand Down
40 changes: 40 additions & 0 deletions ptvsd/_vendored/pydevd/tests_python/test_pydevd_io.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _pydevd_bundle.pydevd_io import IORedirector
from _pydevd_bundle.pydevd_comm import NetCommandFactory


def test_io_redirector():
Expand All @@ -12,3 +13,42 @@ class MyRedirection2(object):
# Check that we don't fail creating the IORedirector if the original
# doesn't have a 'buffer'.
IORedirector(MyRedirection1(), MyRedirection2(), wrap_buffer=True)


class _DummyWriter(object):

__slots__ = ['commands', 'command_meanings']

def __init__(self):
self.commands = []
self.command_meanings = []

def add_command(self, cmd):
from _pydevd_bundle.pydevd_comm import ID_TO_MEANING
meaning = ID_TO_MEANING[str(cmd.id)]
self.command_meanings.append(meaning)
self.commands.append(cmd)

class _DummyPyDb(object):

def __init__(self):
self.cmd_factory = NetCommandFactory()
self.writer = _DummyWriter()


def test_debug_console():
from _pydev_bundle.pydev_console_utils import DebugConsoleStdIn

class OriginalStdin(object):

def readline(self):
return 'read'

original_stdin = OriginalStdin()

py_db = _DummyPyDb()
debug_console_std_in = DebugConsoleStdIn(py_db, original_stdin)
assert debug_console_std_in.readline() == 'read'

assert py_db.writer.command_meanings == ['CMD_INPUT_REQUESTED', 'CMD_INPUT_REQUESTED']

0 comments on commit d3d3345

Please sign in to comment.