mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 00:49:33 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
eb634f9e13
commit
aa6894a436
@@ -118,7 +118,7 @@ class Command(NoArgsCommand):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Failure while trying to import the toaster config file %s: %s" %\
|
print("Failure while trying to import the toaster config file %s: %s" %\
|
||||||
(config_file, e))
|
(config_file, e))
|
||||||
traceback.print_exc(e)
|
traceback.print_exc()
|
||||||
|
|
||||||
return is_changed
|
return is_changed
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class Command(NoArgsCommand):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("runbuilds: Error launching build %s" % e)
|
logger.error("runbuilds: Error launching build %s" % e)
|
||||||
traceback.print_exc(e)
|
traceback.print_exc()
|
||||||
if "[Errno 111] Connection refused" in str(e):
|
if "[Errno 111] Connection refused" in str(e):
|
||||||
# Connection refused, read toaster_server.out
|
# Connection refused, read toaster_server.out
|
||||||
errmsg = bec.readServerLogFile()
|
errmsg = bec.readServerLogFile()
|
||||||
@@ -78,7 +78,7 @@ class Command(NoArgsCommand):
|
|||||||
BRError.objects.create(req = br,
|
BRError.objects.create(req = br,
|
||||||
errtype = str(type(e)),
|
errtype = str(type(e)),
|
||||||
errmsg = errmsg,
|
errmsg = errmsg,
|
||||||
traceback = traceback.format_exc(e))
|
traceback = traceback.format_exc())
|
||||||
br.state = BuildRequest.REQ_FAILED
|
br.state = BuildRequest.REQ_FAILED
|
||||||
br.save()
|
br.save()
|
||||||
bec.be.lock = BuildEnvironment.LOCK_FREE
|
bec.be.lock = BuildEnvironment.LOCK_FREE
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ def execute_tests(dir_under_test, testname):
|
|||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
import traceback
|
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:
|
finally:
|
||||||
os.chdir(crt_dir)
|
os.chdir(crt_dir)
|
||||||
return len(result.failures)
|
return len(result.failures)
|
||||||
@@ -211,7 +211,7 @@ def main():
|
|||||||
|
|
||||||
except ShellCmdException as exc:
|
except ShellCmdException as exc:
|
||||||
import traceback
|
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:
|
finally:
|
||||||
if need_cleanup and testdir is not None:
|
if need_cleanup and testdir is not None:
|
||||||
clean_up(testdir)
|
clean_up(testdir)
|
||||||
|
|||||||
@@ -1217,7 +1217,7 @@ class LayerIndexLayerSource(LayerSource):
|
|||||||
import traceback
|
import traceback
|
||||||
if proxy_settings is not None:
|
if proxy_settings is not None:
|
||||||
logger.info("EE: Using proxy %s" % proxy_settings)
|
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
|
return
|
||||||
|
|
||||||
# update branches; only those that we already have names listed in the
|
# update branches; only those that we already have names listed in the
|
||||||
|
|||||||
@@ -761,7 +761,7 @@ def _get_dir_entries(build_id, target_id, start):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Exception ", e)
|
print("Exception ", e)
|
||||||
traceback.print_exc(e)
|
traceback.print_exc()
|
||||||
|
|
||||||
# sort by directories first, then by name
|
# sort by directories first, then by name
|
||||||
rsorted = sorted(response, key=lambda entry : entry['name'])
|
rsorted = sorted(response, key=lambda entry : entry['name'])
|
||||||
|
|||||||
Reference in New Issue
Block a user