Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH 0/2] Exception handling fixes
@ 2012-09-07 15:22 Paul Eggleton
  2012-09-07 15:22 ` [PATCH 1/2] fetch2: fix malformed URL causing a useless traceback Paul Eggleton
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paul Eggleton @ 2012-09-07 15:22 UTC (permalink / raw)
  To: bitbake-devel

The following changes (against Poky, but apply cleanly with -p2 against
bitbake master) are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib paule/bb-brokenexcept
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/bb-brokenexcept

Paul Eggleton (2):
  fetch2: fix malformed URL causing a useless traceback
  cooker: fix handling of exceptions during exception handling

 bitbake/lib/bb/cooker.py          |    9 +++++++--
 bitbake/lib/bb/fetch2/__init__.py |    4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

-- 
1.7.9.5




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] fetch2: fix malformed URL causing a useless traceback
  2012-09-07 15:22 [PATCH 0/2] Exception handling fixes Paul Eggleton
@ 2012-09-07 15:22 ` Paul Eggleton
  2012-09-07 15:22 ` [PATCH 2/2] cooker: fix handling of exceptions during exception handling Paul Eggleton
  2012-09-10 12:14 ` [PATCH 0/2] Exception handling fixes Richard Purdie
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2012-09-07 15:22 UTC (permalink / raw)
  To: bitbake-devel

The implementation of NoMethodError and MalformedUrl was broken - if you
just set self.args in an exception class to a string it treats it as a
list and then fails later on with a TypeError due to the number of
arguments not matching up.

This nasty exception during exception handling was breaking the normal
exception flow (fixed separately), which meant that if you had a
malformed URL or invalid protocol in SRC_URI you would get the
following:

ERROR: Command execution failed: Traceback (most recent call last):
  File "/home/user/poky/poky/bitbake/lib/bb/command.py", line 84, in runAsyncCommand
    self.cooker.updateCache()
  File "/home/user/poky/poky/bitbake/lib/bb/cooker.py", line 1207, in updateCache
    if not self.parser.parse_next():
  File "/home/user/poky/poky/bitbake/lib/bb/cooker.py", line 1694, in parse_next
    logger.error('Unable to parse %s', value.recipe,
AttributeError: 'exceptions.TypeError' object has no attribute 'recipe'

A specific fix for [YOCTO #2977].

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bitbake/lib/bb/fetch2/__init__.py |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index fae1add..37f7d75 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -54,7 +54,7 @@ class MalformedUrl(BBFetchException):
          msg = "The URL: '%s' is invalid and cannot be interpreted" % url
          self.url = url
          BBFetchException.__init__(self, msg)
-         self.args = url
+         self.args = (url,)
 
 class FetchError(BBFetchException):
     """General fetcher exception when something happens incorrectly"""
@@ -87,7 +87,7 @@ class NoMethodError(BBFetchException):
          msg = "Could not find a fetcher which supports the URL: '%s'" % url
          self.url = url
          BBFetchException.__init__(self, msg)
-         self.args = url
+         self.args = (url,)
 
 class MissingParameterError(BBFetchException):
     """Exception raised when a fetch method is missing a critical parameter in the url"""
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] cooker: fix handling of exceptions during exception handling
  2012-09-07 15:22 [PATCH 0/2] Exception handling fixes Paul Eggleton
  2012-09-07 15:22 ` [PATCH 1/2] fetch2: fix malformed URL causing a useless traceback Paul Eggleton
@ 2012-09-07 15:22 ` Paul Eggleton
  2012-09-10 12:14 ` [PATCH 0/2] Exception handling fixes Richard Purdie
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2012-09-07 15:22 UTC (permalink / raw)
  To: bitbake-devel

If an exception occurs during handling another exception we were
getting a useless traceback such as the following, after which
BitBake froze:

ERROR: Command execution failed: Traceback (most recent call last):
  File "/home/user/poky/poky/bitbake/lib/bb/command.py", line 84, in runAsyncCommand
    self.cooker.updateCache()
  File "/home/user/poky/poky/bitbake/lib/bb/cooker.py", line 1207, in updateCache
    if not self.parser.parse_next():
  File "/home/user/poky/poky/bitbake/lib/bb/cooker.py", line 1694, in parse_next
    logger.error('Unable to parse %s', value.recipe,
AttributeError: 'exceptions.TypeError' object has no attribute 'recipe'

Fix this to print an actual traceback of the exception and exit
gracefully (well, as gracefully as possible under the circumstances).

The general fix for [YOCTO #2977].

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bitbake/lib/bb/cooker.py |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 1b3bb84..19173ae 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1691,8 +1691,13 @@ class CookerParser(object):
         except Exception as exc:
             self.error += 1
             etype, value, tb = sys.exc_info()
-            logger.error('Unable to parse %s', value.recipe,
-                         exc_info=(etype, value, exc.traceback))
+            if hasattr(value, "recipe"):
+                logger.error('Unable to parse %s', value.recipe,
+                            exc_info=(etype, value, exc.traceback))
+            else:
+                # Most likely, an exception occurred during raising an exception
+                import traceback
+                logger.error('Exception during parse: %s' % traceback.format_exc())
             self.shutdown(clean=False)
             return False
 
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Exception handling fixes
  2012-09-07 15:22 [PATCH 0/2] Exception handling fixes Paul Eggleton
  2012-09-07 15:22 ` [PATCH 1/2] fetch2: fix malformed URL causing a useless traceback Paul Eggleton
  2012-09-07 15:22 ` [PATCH 2/2] cooker: fix handling of exceptions during exception handling Paul Eggleton
@ 2012-09-10 12:14 ` Richard Purdie
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Purdie @ 2012-09-10 12:14 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: bitbake-devel

On Fri, 2012-09-07 at 16:22 +0100, Paul Eggleton wrote:
> The following changes (against Poky, but apply cleanly with -p2 against
> bitbake master) are available in the git repository at:
> 
>   git://git.yoctoproject.org/poky-contrib paule/bb-brokenexcept
>   http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/bb-brokenexcept
> 
> Paul Eggleton (2):
>   fetch2: fix malformed URL causing a useless traceback
>   cooker: fix handling of exceptions during exception handling

Merged to master, thanks.

Richard




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-10 12:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-07 15:22 [PATCH 0/2] Exception handling fixes Paul Eggleton
2012-09-07 15:22 ` [PATCH 1/2] fetch2: fix malformed URL causing a useless traceback Paul Eggleton
2012-09-07 15:22 ` [PATCH 2/2] cooker: fix handling of exceptions during exception handling Paul Eggleton
2012-09-10 12:14 ` [PATCH 0/2] Exception handling fixes Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox