From bb7375da31ade1f4a103806cd5c449baf8b25a94 Mon Sep 17 00:00:00 2001 From: Pavel Minaev Date: Mon, 22 Jul 2019 15:59:48 -0700 Subject: [PATCH] Fix test_launcher on Python 2.7. --- tests/ptvsd/common/test_launcher.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/ptvsd/common/test_launcher.py b/tests/ptvsd/common/test_launcher.py index 4a3697ab..ae01b18b 100644 --- a/tests/ptvsd/common/test_launcher.py +++ b/tests/ptvsd/common/test_launcher.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, print_function, unicode_literals +import errno import os.path import platform import pytest @@ -114,14 +115,16 @@ def test_launcher(pyfile, mode, exit_code, run_as): while not outstr.endswith(b". . . "): outstr += p.stdout.read(1) + exc_type = BrokenPipeError if sys.version_info >= (3,) else IOError + while p.poll() is None: try: p.stdin.write(b"\n") p.stdin.flush() - except BrokenPipeError: - # This can occur if the console exited before - # flush was called. - pass + except exc_type as exc: + # This can occur if the process exits before write completes. + if isinstance(exc, IOError) and exc.errno != errno.EPIPE: + raise else: p.wait()