yapps sends errors to stderr not stdout
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 02 Dec 2014 11:07:14 +0100
changeset 788 370ca06d0088
parent 787 1e22b3458e87
child 789 7b01294f336d
yapps sends errors to stderr not stdout Capturing the latter only results in an empty StringIO.
rql/__init__.py
--- a/rql/__init__.py	Thu Nov 19 13:54:44 2015 +0100
+++ b/rql/__init__.py	Tue Dec 02 11:07:14 2014 +0100
@@ -230,17 +230,17 @@
             raise exc
         # try to get error message from yapps
         try:
-            out = sys.stdout
-            sys.stdout = stream = StringIO()
+            out = sys.stderr
+            sys.stderr = stream = StringIO()
             try:
                 print_error(ex, parser._scanner)
             finally:
-                sys.stdout = out
+                sys.stderr = out
             exc = RQLSyntaxError(stream.getvalue())
             exc.__traceback__ = sys.exc_info()[-1]
             raise exc
         except ImportError: # duh?
-            sys.stdout = out
+            sys.stderr = out
             exc = RQLSyntaxError('Syntax Error', ex.msg, 'on line',
                                  1 + pinput.count('\n', 0, ex.pos))
             exc.__traceback__ = sys.exc_info()[-1]