[oe-commits] [bitbake] branch master updated: bitbake: fix wrong usage of format_exc

git at git.openembedded.org git at git.openembedded.org
Thu Jun 16 10:51:55 UTC 2016


rpurdie pushed a commit to branch master
in repository bitbake.

The following commit(s) were added to refs/heads/master by this push:
       new  a950994   bitbake: fix wrong usage of format_exc
a950994 is described below

commit a9509949d7e2adba6e3cd89f97daa19a955855b5
Author: Ed Bartosh <eduard.bartosh at intel.com>
AuthorDate: Fri Jun 10 14:58:17 2016 +0300

    bitbake: fix wrong usage of format_exc
    
    First parameter of traceback.format_exc is a 'limit' - a number
    of stracktraces to format.
    
    Passing exception object to format_exc is incorrect, but it works in
    Python 2 as this code from traceback module works:
        while tb is not None and (limit is None or n < limit):
    Comparing integer counter n with the exception object in Python 2
    always results in True. However, in Python 3 it throws exception:
        TypeError: unorderable types: int() < <Exception type>()
    
    As format_exc is used in except block of handling another
    exception this can cause hard to find and debug bugs.
    
    Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/cooker.py     | 2 +-
 lib/bb/ui/uievent.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 9075654..60ee5d7 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -330,7 +330,7 @@ class BBCooker:
                                 f.write("%s\n" % json.dumps({"class":event.__module__ + "." + event.__class__.__name__, "vars":json.dumps(pickle.dumps(event)) }))
                             except Exception as e:
                                 import traceback
-                                print(e, traceback.format_exc(e))
+                                print(e, traceback.format_exc())
 
 
                     def send(self, event):
diff --git a/lib/bb/ui/uievent.py b/lib/bb/ui/uievent.py
index ca19166..9542b91 100644
--- a/lib/bb/ui/uievent.py
+++ b/lib/bb/ui/uievent.py
@@ -116,7 +116,7 @@ class BBUIEventQueue:
                 self.server.handle_request()
             except Exception as e:
                 import traceback
-                logger.error("BBUIEventQueue.startCallbackHandler: Exception while trying to handle request: %s\n%s" % (e, traceback.format_exc(e)))
+                logger.error("BBUIEventQueue.startCallbackHandler: Exception while trying to handle request: %s\n%s" % (e, traceback.format_exc()))
 
         self.server.server_close()
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list