[openstack-dev] [oslo] Logging exceptions and Python 3

Igor Kalnitsky ikalnitsky at mirantis.com
Fri May 16 13:31:46 UTC 2014


> unicode(exc) (or six.text_type(exc)) works for all exceptions, built-in or
custom.

That's too much of a statement. Sometimes exceptions implement their own
__str__ / __unitcode__
methods, that return too many rubbish information or not enough. What do
you do in that case?

BTW, I don't say that we have to skip `six.text_type(exc)` approach. I'm
just saying, that it's not
a panacea in real world.

> six.text_type(exc) is the recommended solution

As I mention in first letter, I vote for this solution since it's a general
case.


On Fri, May 16, 2014 at 4:03 PM, Johannes Erdfelt <johannes at erdfelt.com>wrote:

> On Fri, May 16, 2014, Igor Kalnitsky <ikalnitsky at mirantis.com> wrote:
> > > According to http://legacy.python.org/dev/peps/pep-0352/ the message
> > > attribute of BaseException is deprecated since Python 2.6 and was
> > > dropped in Python 3.0.
> >
> > Some projects have custom exception hierarchy, with strictly defined
> > attributes (e.g. message, or something else). In a previous mail, I
> > mean exactly that case, not the case with a built-in exceptions.
>
> That's a fragile assumption to make.
>
> unicode(exc) (or six.text_type(exc)) works for all exceptions, built-in
> or custom. I don't see the reason why it's being avoided.
>
> JE
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140516/0217fd1b/attachment.html>


More information about the OpenStack-dev mailing list