diff options
| author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-06-10 12:34:12 +0300 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-15 08:35:06 +0100 |
| commit | aa6894a4369dbbd032a98bfe43b285111261efa9 (patch) | |
| tree | 2fe0bb1b09d1fe1551899bfdbf324c75370fac45 | |
| parent | eb634f9e13ade09b4fc7d69801f4d9e21ef03db1 (diff) | |
| download | poky-aa6894a4369dbbd032a98bfe43b285111261efa9.tar.gz | |
bitbake: toaster: fix wrong usage of print_exc and format_exc
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.
(Bitbake rev: c5a48931ac8db9e56f978c50861c19d0d0c808e3)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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 2407e1bbcc..8cdc81311f 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): | |||
| 118 | except Exception as e: | 118 | except Exception as e: |
| 119 | print("Failure while trying to import the toaster config file %s: %s" %\ | 119 | print("Failure while trying to import the toaster config file %s: %s" %\ |
| 120 | (config_file, e)) | 120 | (config_file, e)) |
| 121 | traceback.print_exc(e) | 121 | traceback.print_exc() |
| 122 | 122 | ||
| 123 | return is_changed | 123 | return is_changed |
| 124 | 124 | ||
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py index 80782ef923..a70377012b 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): | |||
| 68 | 68 | ||
| 69 | except Exception as e: | 69 | except Exception as e: |
| 70 | logger.error("runbuilds: Error launching build %s" % e) | 70 | logger.error("runbuilds: Error launching build %s" % e) |
| 71 | traceback.print_exc(e) | 71 | traceback.print_exc() |
| 72 | if "[Errno 111] Connection refused" in str(e): | 72 | if "[Errno 111] Connection refused" in str(e): |
| 73 | # Connection refused, read toaster_server.out | 73 | # Connection refused, read toaster_server.out |
| 74 | errmsg = bec.readServerLogFile() | 74 | errmsg = bec.readServerLogFile() |
| @@ -78,7 +78,7 @@ class Command(NoArgsCommand): | |||
| 78 | BRError.objects.create(req = br, | 78 | BRError.objects.create(req = br, |
| 79 | errtype = str(type(e)), | 79 | errtype = str(type(e)), |
| 80 | errmsg = errmsg, | 80 | errmsg = errmsg, |
| 81 | traceback = traceback.format_exc(e)) | 81 | traceback = traceback.format_exc()) |
| 82 | br.state = BuildRequest.REQ_FAILED | 82 | br.state = BuildRequest.REQ_FAILED |
| 83 | br.save() | 83 | br.save() |
| 84 | bec.be.lock = BuildEnvironment.LOCK_FREE | 84 | 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 bed665196e..d01386acfa 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): | |||
| 146 | 146 | ||
| 147 | except Exception as exc: | 147 | except Exception as exc: |
| 148 | import traceback | 148 | import traceback |
| 149 | config.logger.error("Exception while running test. Tracedump: \n%s", traceback.format_exc(exc)) | 149 | config.logger.error("Exception while running test. Tracedump: \n%s", traceback.format_exc()) |
| 150 | finally: | 150 | finally: |
| 151 | os.chdir(crt_dir) | 151 | os.chdir(crt_dir) |
| 152 | return len(result.failures) | 152 | return len(result.failures) |
| @@ -211,7 +211,7 @@ def main(): | |||
| 211 | 211 | ||
| 212 | except ShellCmdException as exc: | 212 | except ShellCmdException as exc: |
| 213 | import traceback | 213 | import traceback |
| 214 | config.logger.error("Error while setting up testing. Traceback: \n%s", traceback.format_exc(exc)) | 214 | config.logger.error("Error while setting up testing. Traceback: \n%s", traceback.format_exc()) |
| 215 | finally: | 215 | finally: |
| 216 | if need_cleanup and testdir is not None: | 216 | if need_cleanup and testdir is not None: |
| 217 | clean_up(testdir) | 217 | clean_up(testdir) |
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index caad2afe81..61737c7979 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
| @@ -1217,7 +1217,7 @@ class LayerIndexLayerSource(LayerSource): | |||
| 1217 | import traceback | 1217 | import traceback |
| 1218 | if proxy_settings is not None: | 1218 | if proxy_settings is not None: |
| 1219 | logger.info("EE: Using proxy %s" % proxy_settings) | 1219 | logger.info("EE: Using proxy %s" % proxy_settings) |
| 1220 | logger.warning("EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc(e))) | 1220 | logger.warning("EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc())) |
| 1221 | return | 1221 | return |
| 1222 | 1222 | ||
| 1223 | # update branches; only those that we already have names listed in the | 1223 | # 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 5ceeb6be3e..02548761f0 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): | |||
| 761 | 761 | ||
| 762 | except Exception as e: | 762 | except Exception as e: |
| 763 | print("Exception ", e) | 763 | print("Exception ", e) |
| 764 | traceback.print_exc(e) | 764 | traceback.print_exc() |
| 765 | 765 | ||
| 766 | # sort by directories first, then by name | 766 | # sort by directories first, then by name |
| 767 | rsorted = sorted(response, key=lambda entry : entry['name']) | 767 | rsorted = sorted(response, key=lambda entry : entry['name']) |
