diff --git a/mypy/errors.py b/mypy/errors.py index 69a0b2725f1d..a3d576e7c00d 100644 --- a/mypy/errors.py +++ b/mypy/errors.py @@ -374,8 +374,10 @@ def report_internal_error(err: Exception, file: str, line: int) -> None: for s in traceback.format_list(tb + tb2): print(s.rstrip('\n')) print('{}: {}'.format(type(err).__name__, err)) - print('\n*** INTERNAL ERROR ***') + print('\n*** INTERNAL ERROR ***', file=sys.stderr) print('\n{}:{}: error: Internal error --'.format(file, line), - 'please report a bug at https://github.com/JukkaL/mypy/issues') - print('\nNOTE: you can use "mypy --pdb ..." to drop into the debugger when this happens.') + 'please report a bug at https://github.com/JukkaL/mypy/issues', + file=sys.stderr) + print('\nNOTE: you can use "mypy --pdb ..." to drop into the debugger when this happens.', + file=sys.stderr) sys.exit(1) diff --git a/mypy/lex.py b/mypy/lex.py index d94878549b12..5c4d0ca756eb 100644 --- a/mypy/lex.py +++ b/mypy/lex.py @@ -880,7 +880,7 @@ def ignore_break(self) -> bool: # Lexically analyze a file and dump the tokens to stdout. import sys if len(sys.argv) != 2: - print('Usage: lex.py FILE') + print('Usage: lex.py FILE', file=sys.stderr) sys.exit(2) fnam = sys.argv[1] s = open(fnam, 'rb').read() diff --git a/mypy/main.py b/mypy/main.py index 5e2f47415d02..f8a8cee6d4cf 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -56,7 +56,7 @@ def main(script_path: str) -> None: raise RuntimeError('unsupported target %d' % options.target) except CompileError as e: for m in e.messages: - sys.stdout.write(m + '\n') + sys.stderr.write(m + '\n') sys.exit(1) diff --git a/mypy/parse.py b/mypy/parse.py index 1408a8a89ba1..5c5d959cd173 100644 --- a/mypy/parse.py +++ b/mypy/parse.py @@ -1978,7 +1978,7 @@ def token_repr(tok: Token) -> str: import sys def usage(): - print('Usage: parse.py [--py2] [--quiet] FILE [...]') + print('Usage: parse.py [--py2] [--quiet] FILE [...]', file=sys.stderr) sys.exit(2) args = sys.argv[1:] diff --git a/mypy/stubgen.py b/mypy/stubgen.py index 45647a7975d0..7d87688aebf3 100644 --- a/mypy/stubgen.py +++ b/mypy/stubgen.py @@ -148,7 +148,7 @@ def load_python_module_info(module: str, interpreter: str) -> Tuple[str, Optiona try: output_bytes = subprocess.check_output(cmd_template % code, shell=True) except subprocess.CalledProcessError: - print("Can't import module %s" % module) + print("Can't import module %s" % module, file=sys.stderr) sys.exit(1) output = output_bytes.decode('ascii').strip().splitlines() module_path = output[0]