mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Merge pull request #12 from int19h/2052
Fix #2052: An error display in output window when debug with "Windows Application" option checked.
This commit is contained in:
commit
a1e4eb3c5e
2 changed files with 42 additions and 4 deletions
|
|
@ -29,11 +29,16 @@ class CaptureOutput(object):
|
|||
self.category = category
|
||||
self._whose = whose
|
||||
self._fd = fd
|
||||
self._stream = stream if sys.version_info < (3,) else stream.buffer
|
||||
self._decoder = codecs.getincrementaldecoder("utf-8")(errors="surrogateescape")
|
||||
self._encode = codecs.getencoder(
|
||||
"utf-8" if stream.encoding is None else stream.encoding
|
||||
)
|
||||
|
||||
if stream is None:
|
||||
# Can happen if running under pythonw.exe.
|
||||
self._stream = None
|
||||
else:
|
||||
self._stream = stream if sys.version_info < (3,) else stream.buffer
|
||||
self._encode = codecs.getencoder(
|
||||
"utf-8" if stream.encoding is None else stream.encoding
|
||||
)
|
||||
|
||||
self._worker_thread = threading.Thread(target=self._worker, name=category)
|
||||
self._worker_thread.start()
|
||||
|
|
@ -71,6 +76,9 @@ class CaptureOutput(object):
|
|||
except Exception:
|
||||
pass # channel to adapter is already closed
|
||||
|
||||
if self._stream is None:
|
||||
return
|
||||
|
||||
s, _ = self._encode(s, "surrogateescape")
|
||||
size = len(s)
|
||||
i = 0
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
from tests import debug
|
||||
from tests.debug import runners
|
||||
|
|
@ -119,3 +120,32 @@ def test_non_ascii_output(pyfile, target, run):
|
|||
b"\xc3\xa9 \xc3\xa0 \xc3\xb6 \xc3\xb9\n",
|
||||
b"\xc3\x83\xc2\xa9 \xc3\x83\xc2\xa0 \xc3\x83\xc2\xb6 \xc3\x83\xc2\xb9\n",
|
||||
)
|
||||
|
||||
|
||||
if sys.platform == "win32":
|
||||
|
||||
@pytest.mark.parametrize("redirect_output", ["", "redirect_output"])
|
||||
def test_pythonw_output(pyfile, target, run, redirect_output):
|
||||
@pyfile
|
||||
def code_to_debug():
|
||||
import debuggee
|
||||
|
||||
debuggee.setup()
|
||||
print("ok")
|
||||
() # @wait_for_output
|
||||
|
||||
with debug.Session() as session:
|
||||
# Don't capture launcher output - we want to see how it handles not
|
||||
# having sys.stdin and sys.stdout available.
|
||||
session.captured_output = set()
|
||||
|
||||
session.config["pythonPath"] = sys.executable + "/../pythonw.exe"
|
||||
session.config["redirectOutput"] = bool(redirect_output)
|
||||
|
||||
with run(session, target(code_to_debug)):
|
||||
session.set_breakpoints(code_to_debug, all)
|
||||
|
||||
session.wait_for_stop()
|
||||
session.request_continue()
|
||||
|
||||
assert session.output("stdout") == ("ok\n" if redirect_output else "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue