]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
toaster: fix wrong usage of print_exc and format_exc
authorEd Bartosh <ed.bartosh@linux.intel.com>
Fri, 10 Jun 2016 09:34:12 +0000 (12:34 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 14 Jun 2016 10:08:59 +0000 (11:08 +0100)
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>
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
lib/toaster/bldcontrol/management/commands/checksettings.py
lib/toaster/bldcontrol/management/commands/runbuilds.py
lib/toaster/contrib/tts/runner.py
lib/toaster/orm/models.py
lib/toaster/toastergui/views.py

index 2407e1bbccf82c1a25945e4f6366bf69ea235ec0..8cdc81311ffcc852e35b06081c7dc1286a982c79 100644 (file)
@@ -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
 
index 80782ef92359c3cb41bea23341724a89448cbc29..a70377012b583e4aa90f8330d59a4a28d5807290 100644 (file)
@@ -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
index bed665196e973aca20327c3141fc0715fc9ef069..d01386acfad1cdfa7e9cfc77effa6d5099c99d35 100755 (executable)
@@ -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)
index caad2afe8172350ee2cdb20492c2d57156f00574..61737c79791dedcdb050aa01c73557d5e3beaff2 100644 (file)
@@ -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
index 5ceeb6be3ed53ed8d360fa8fa1d65db5566e8ee4..02548761f0433c64491fafdfa6779f82c57e5f5f 100755 (executable)
@@ -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'])