← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-stacktrace into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-stacktrace into launchpad:master.

Commit message:
Fix lp.services.stacktrace tests for Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396330

DEBUG_EXCEPTION_FORMATTER needs to write to sys.stderr rather than sys.stdout.  This is what the tests expect, and it makes more sense anyway.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-stacktrace into launchpad:master.
diff --git a/lib/lp/services/stacktrace.py b/lib/lp/services/stacktrace.py
index 39105bc..6b3cacb 100644
--- a/lib/lp/services/stacktrace.py
+++ b/lib/lp/services/stacktrace.py
@@ -31,7 +31,7 @@ def _try_except(callable, *args, **kwargs):
         raise
     except:
         if DEBUG_EXCEPTION_FORMATTER:
-            traceback.print_exc()
+            traceback.print_exc(file=sys.stderr)
     # return None
 
 
@@ -104,7 +104,7 @@ def format_list(extracted_list):
             # The values above may not stringify properly, or who knows what
             # else.  Be defensive.
             if DEBUG_EXCEPTION_FORMATTER:
-                traceback.print_exc()
+                traceback.print_exc(file=sys.stderr)
             # else just swallow the exception.
         item.append('')  # This gives us a trailing newline.
         list.append('\n'.join(item))
@@ -172,7 +172,7 @@ def _get_frame_data(f, lineno):
                 raise
             except:
                 if DEBUG_EXCEPTION_FORMATTER:
-                    traceback.print_exc()
+                    traceback.print_exc(file=sys.stderr)
             supplement_dict = dict(warnings=warnings, extra=extra)
             for key in ('source_url', 'line', 'column', 'expression'):
                 value = getattr(supplement, key, None)