On Wed, Sep 19, 2012 at 01:26:29PM +0200, Zdeněk Pavlas wrote:
> ---
>  urlgrabber/grabber.py |    6 ++++++
>  urlgrabber/mirror.py  |    3 ++-
>  2 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
> index 01218b0..0e20cee 100644
> --- a/urlgrabber/grabber.py
> +++ b/urlgrabber/grabber.py
> @@ -621,6 +621,12 @@ def _to_utf8(obj, errors='replace'):
>          obj = obj.encode('utf-8', errors)
>      return obj
>  
> +def exception2msg(e):
> +    try:
> +        return str(e)
> +    except UnicodeEncodeError:
> +        return unicode(e)
> +

There's multiple ways that this could fail and still raise an exception.  In
addition, the code that uses exception2msg could also start throwing
exceptions depending on what it's getting back from this method.  I think
you'd be better off using kitchen or copying it's code.

Documentation:
http://packages.python.org/kitchen/api-text-converters.html#working-with-exception-messages

Code:
http://bzr.fedorahosted.org/bzr/kitchen/devel/annotate/head:/kitchen/text/converters.py#L413

(to line 544)

-Toshio

Attachment: pgpoP7SGWIfHD.pgp
Description: PGP signature

_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to