[OE-core] [PATCH 1/1] bbclass: bb.fatal() clean up

Robert Yang liezhi.yang at windriver.com
Thu May 9 02:14:58 UTC 2013



On 05/08/2013 08:03 PM, Mike Looijmans wrote:
> On 05/08/2013 11:06 AM, Robert Yang wrote:
>> The bb.fatal() is defined as:
>>
>> def fatal(*args):
>>      logger.critical(''.join(args))
>>      sys.exit(1)
>>
>> So anything after bb.fatal() in the same code block doesn't have any
>> effect, e.g.:
>>
>>      bb.fatal("%s_%s: %s" % (var, pkg, e))
>>      raise e
>>
>> The "raise e" should be removed.
>
> Just some random thoughts that occurred to me when I read this:
>

Hi Mike, thanks for your comments, but the "raise sys.exit(1)" doesn't raise
anything, e.g.:

import sys

def fatal():
         sys.exit(1)

try:
         raise fatal()
except Exception as e:
         raise e

I think that the "raise fatal()" equals to "fatal()" here.

// Robert

> The "terminate" effect would be obvious if "fatal" were an exception to be
> raised instead of a function to call which does not really return. If I'm not
> mistaken, "sys.exit(1)" actually just raises a SystemExit exception.
>
> So instead of:
>
> bb.fatal("something went wrong")
>
> the syntax would become:
>
> raise bb.Fatal("something went wrong")
>
>
> Having typed this, the next random thought I got was that a thing like
>
> catch Exception, e:
>     bb.fatal("Error: ", e)
>
> isn't really adding anything useful, it just "translates" the exception, logs
> its message, and then throws an obscure system exit exception instead of the
> much more useful inner exception.
>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
>




More information about the Openembedded-core mailing list