summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2015-01-26 12:36:13 -0500
committerBarry Warsaw <barry@python.org>2015-01-26 12:36:13 -0500
commite085d5cec212757e0ffffaa1be470e315142a2aa (patch)
treeda246ad4cc3ac3894f3d2d2d2288de5541e5bc27
parent0e7e5041a0ef80099c48341952e881009eb65fdf (diff)
downloadvyos-cloud-init-e085d5cec212757e0ffffaa1be470e315142a2aa.tar.gz
vyos-cloud-init-e085d5cec212757e0ffffaa1be470e315142a2aa.zip
Avoid a nose bug when running under the test suite and no exception is in
flight.
-rw-r--r--cloudinit/util.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 25c104c7..d594b611 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1236,8 +1236,15 @@ def logexc(log, msg, *args):
# coming out to a non-debug stream
if msg:
log.warn(msg, *args)
- # Debug gets the full trace
- log.debug(msg, exc_info=1, *args)
+ # Debug gets the full trace. However, nose has a bug whereby its
+ # logcapture plugin doesn't properly handle the case where there is no
+ # actual exception. To avoid tracebacks during the test suite then, we'll
+ # do the actual exc_info extraction here, and if there is no exception in
+ # flight, we'll just pass in None.
+ exc_info = sys.exc_info()
+ if exc_info == (None, None, None):
+ exc_info = None
+ log.debug(msg, exc_info=exc_info, *args)
def hash_blob(blob, routine, mlen=None):