From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: toaster@yoctoproject.org
Subject: [PATCH] toaster: fix wrong usage of print_exc and format_exc
Date: Fri, 10 Jun 2016 12:34:12 +0300 [thread overview]
Message-ID: <1465551252-10239-1-git-send-email-ed.bartosh@linux.intel.com> (raw)
First parameter of traceback.print_exc and traceback.format_exc APIs is
a 'limit' - a number of stracktraces to print.
Passing exception object to print_exc or format_exc is incorrect, but
it works in Python 2 and causes printing only one line of traceback.
In Python 3 comparison of integer and exception object throws exception:
TypeError: unorderable types: int() < <Exception type>()
As these APIs are usually used in except block of handling another
exception this can cause hard to find and debug bugs.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py | 2 +-
bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py | 4 ++--
bitbake/lib/toaster/contrib/tts/runner.py | 4 ++--
bitbake/lib/toaster/orm/models.py | 2 +-
bitbake/lib/toaster/toastergui/views.py | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
index 2407e1b..8cdc813 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
@@ -118,7 +118,7 @@ class Command(NoArgsCommand):
except Exception as e:
print("Failure while trying to import the toaster config file %s: %s" %\
(config_file, e))
- traceback.print_exc(e)
+ traceback.print_exc()
return is_changed
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
index 80782ef..a703770 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -68,7 +68,7 @@ class Command(NoArgsCommand):
except Exception as e:
logger.error("runbuilds: Error launching build %s" % e)
- traceback.print_exc(e)
+ traceback.print_exc()
if "[Errno 111] Connection refused" in str(e):
# Connection refused, read toaster_server.out
errmsg = bec.readServerLogFile()
@@ -78,7 +78,7 @@ class Command(NoArgsCommand):
BRError.objects.create(req = br,
errtype = str(type(e)),
errmsg = errmsg,
- traceback = traceback.format_exc(e))
+ traceback = traceback.format_exc())
br.state = BuildRequest.REQ_FAILED
br.save()
bec.be.lock = BuildEnvironment.LOCK_FREE
diff --git a/bitbake/lib/toaster/contrib/tts/runner.py b/bitbake/lib/toaster/contrib/tts/runner.py
index bed6651..d01386a 100755
--- a/bitbake/lib/toaster/contrib/tts/runner.py
+++ b/bitbake/lib/toaster/contrib/tts/runner.py
@@ -146,7 +146,7 @@ def execute_tests(dir_under_test, testname):
except Exception as exc:
import traceback
- config.logger.error("Exception while running test. Tracedump: \n%s", traceback.format_exc(exc))
+ config.logger.error("Exception while running test. Tracedump: \n%s", traceback.format_exc())
finally:
os.chdir(crt_dir)
return len(result.failures)
@@ -211,7 +211,7 @@ def main():
except ShellCmdException as exc:
import traceback
- config.logger.error("Error while setting up testing. Traceback: \n%s", traceback.format_exc(exc))
+ config.logger.error("Error while setting up testing. Traceback: \n%s", traceback.format_exc())
finally:
if need_cleanup and testdir is not None:
clean_up(testdir)
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index caad2af..61737c7 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1217,7 +1217,7 @@ class LayerIndexLayerSource(LayerSource):
import traceback
if proxy_settings is not None:
logger.info("EE: Using proxy %s" % proxy_settings)
- logger.warning("EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc(e)))
+ logger.warning("EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc()))
return
# update branches; only those that we already have names listed in the
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 9d06000..3e6a392 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -761,7 +761,7 @@ def _get_dir_entries(build_id, target_id, start):
except Exception as e:
print("Exception ", e)
- traceback.print_exc(e)
+ traceback.print_exc()
# sort by directories first, then by name
rsorted = sorted(response, key=lambda entry : entry['name'])
--
2.1.4
reply other threads:[~2016-06-10 9:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1465551252-10239-1-git-send-email-ed.bartosh@linux.intel.com \
--to=ed.bartosh@linux.intel.com \
--cc=toaster@yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.