From f9a6d7d49425a04b10e4373077230c6cb93c5817 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 14 Sep 1998 16:22:21 +0000 Subject: Print serious errors to stderr instead of stdout. --- Lib/tabnanny.py | 15 +++++++++++---- Tools/idle/tabnanny.py | 15 +++++++++++---- Tools/scripts/tabnanny.py | 15 +++++++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py index a9bd9dc..0ffdba1 100755 --- a/Lib/tabnanny.py +++ b/Lib/tabnanny.py @@ -13,18 +13,25 @@ import tokenize verbose = 0 +def errprint(*args): + sep = "" + for arg in args: + sys.stderr.write(sep + str(arg)) + sep = " " + sys.stderr.write("\n") + def main(): global verbose try: opts, args = getopt.getopt(sys.argv[1:], "v") except getopt.error, msg: - print msg + errprint(msg) return for o, a in opts: if o == '-v': verbose = verbose + 1 if not args: - print "Usage:", sys.argv[0], "[-v] file_or_directory ..." + errprint("Usage:", sys.argv[0], "[-v] file_or_directory ...") return for arg in args: check(arg) @@ -55,7 +62,7 @@ def check(file): try: f = open(file) except IOError, msg: - print "%s: I/O Error: %s" % (`file`, str(msg)) + errprint("%s: I/O Error: %s" % (`file`, str(msg))) return if verbose > 1: @@ -66,7 +73,7 @@ def check(file): tokenize.tokenize(f.readline, tokeneater) except tokenize.TokenError, msg: - print "%s: Token Error: %s" % (`file`, str(msg)) + errprint("%s: Token Error: %s" % (`file`, str(msg))) return except NannyNag, nag: diff --git a/Tools/idle/tabnanny.py b/Tools/idle/tabnanny.py index a9bd9dc..0ffdba1 100755 --- a/Tools/idle/tabnanny.py +++ b/Tools/idle/tabnanny.py @@ -13,18 +13,25 @@ import tokenize verbose = 0 +def errprint(*args): + sep = "" + for arg in args: + sys.stderr.write(sep + str(arg)) + sep = " " + sys.stderr.write("\n") + def main(): global verbose try: opts, args = getopt.getopt(sys.argv[1:], "v") except getopt.error, msg: - print msg + errprint(msg) return for o, a in opts: if o == '-v': verbose = verbose + 1 if not args: - print "Usage:", sys.argv[0], "[-v] file_or_directory ..." + errprint("Usage:", sys.argv[0], "[-v] file_or_directory ...") return for arg in args: check(arg) @@ -55,7 +62,7 @@ def check(file): try: f = open(file) except IOError, msg: - print "%s: I/O Error: %s" % (`file`, str(msg)) + errprint("%s: I/O Error: %s" % (`file`, str(msg))) return if verbose > 1: @@ -66,7 +73,7 @@ def check(file): tokenize.tokenize(f.readline, tokeneater) except tokenize.TokenError, msg: - print "%s: Token Error: %s" % (`file`, str(msg)) + errprint("%s: Token Error: %s" % (`file`, str(msg))) return except NannyNag, nag: diff --git a/Tools/scripts/tabnanny.py b/Tools/scripts/tabnanny.py index a9bd9dc..0ffdba1 100755 --- a/Tools/scripts/tabnanny.py +++ b/Tools/scripts/tabnanny.py @@ -13,18 +13,25 @@ import tokenize verbose = 0 +def errprint(*args): + sep = "" + for arg in args: + sys.stderr.write(sep + str(arg)) + sep = " " + sys.stderr.write("\n") + def main(): global verbose try: opts, args = getopt.getopt(sys.argv[1:], "v") except getopt.error, msg: - print msg + errprint(msg) return for o, a in opts: if o == '-v': verbose = verbose + 1 if not args: - print "Usage:", sys.argv[0], "[-v] file_or_directory ..." + errprint("Usage:", sys.argv[0], "[-v] file_or_directory ...") return for arg in args: check(arg) @@ -55,7 +62,7 @@ def check(file): try: f = open(file) except IOError, msg: - print "%s: I/O Error: %s" % (`file`, str(msg)) + errprint("%s: I/O Error: %s" % (`file`, str(msg))) return if verbose > 1: @@ -66,7 +73,7 @@ def check(file): tokenize.tokenize(f.readline, tokeneater) except tokenize.TokenError, msg: - print "%s: Token Error: %s" % (`file`, str(msg)) + errprint("%s: Token Error: %s" % (`file`, str(msg))) return except NannyNag, nag: -- cgit v0.12