On 05/21/2014 12:11 PM, Igor Kalnitsky wrote:
>> So, write:
>>
>> LOG.debug(u'Could not do whatever you asked: %s', exc)
>>
>> or just:
>>
>> LOG.debug(exc)
>
> Actually, that's a bad idea to pass an exception instance to
> some log function: LOG.debug(exc). Let me show you why.
>
> Here
On Wed, May 21, 2014, John Dennis wrote:
> But that's a bug in the logging implementation. Are we supposed to write
> perverse code just to avoid coding mistakes in other modules? Why not
> get the fundamental problem fixed?
It has been fixed, by making Python 3 :)
This is a problem in the Pytho
On 05/21/2014 01:11 PM, Igor Kalnitsky wrote:
>> So, write:
>>
>> LOG.debug(u'Could not do whatever you asked: %s', exc)
>>
>> or just:
>>
>> LOG.debug(exc)
>
> Actually, that's a bad idea to pass an exception instance to
> some log function: LOG.debug(exc). Let me show you why.
>
> Here
> So, write:
>
> LOG.debug(u'Could not do whatever you asked: %s', exc)
>
> or just:
>
> LOG.debug(exc)
Actually, that's a bad idea to pass an exception instance to
some log function: LOG.debug(exc). Let me show you why.
Here a snippet from logging.py:
def getMessage(self):
i
On Thu, May 15, 2014 at 11:29 AM, Victor Stinner
wrote:
> Hi,
>
> I'm trying to define some rules to port OpenStack code to Python 3. I just
> added a section in the "Port Python 2 code to Python 3" about formatting
> exceptions and the logging module:
> https://wiki.openstack.org/wiki/Python3#log
On 05/16/2014 09:11 AM, Johannes Erdfelt wrote:
> six.text_type(exc) is the recommended solution.
+1
--
John
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
*@Victor:*
> " six.text_type(exc): always use Unicode. It may raise unicode error
depending
> on the exception, be careful. Example of such error in python 2:
> unicode(Exception("nonascii:\xe9")). "
It's very rare situation. Actually, it's no sense since we know nothing
about exception's encodin
On Fri, May 16, 2014, Igor Kalnitsky wrote:
> > 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 eno
On Fri, May 16, 2014, Victor Stinner wrote:
> See my documentation:
> https://wiki.openstack.org/wiki/Python3#logging_module_and_format_exceptions
>
> " six.text_type(exc): always use Unicode. It may raise unicode error
> depending
> on the exception, be careful. Example of such error in python
-
From: Victor Stinner
Organization: eNovance
Reply-To: "OpenStack Development Mailing List (not for usage questions)"
Date: Friday, May 16, 2014 at 7:04 AM
To: "OpenStack Development Mailing List (not for usage questions)"
Subject: Re: [openstack-dev] [oslo] Logging exc
Le vendredi 16 mai 2014, 06:03:53 Johannes Erdfelt a écrit :
> On Fri, May 16, 2014, Igor Kalnitsky 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 p
> 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
On Thu, May 15, 2014, Victor Stinner wrote:
> I'm trying to define some rules to port OpenStack code to Python 3. I just
> added a section in the "Port Python 2 code to Python 3" about formatting
> exceptions and the logging module:
> https://wiki.openstack.org/wiki/Python3#logging_module_and_fo
On Fri, May 16, 2014, Igor Kalnitsky 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
> attribut
k.org>
> Date: Thursday, May 15, 2014 at 2:20 PM
> To: "OpenStack Development Mailing List (not for usage questions)" <
> openstack-dev@lists.openstack.org>
> Subject: Re: [openstack-dev] [oslo] Logging exceptions and Python 3
>
>Hi,
>
> > Is
v@lists.openstack.org>>
Subject: Re: [openstack-dev] [oslo] Logging exceptions and Python 3
Hi,
> Is there a reason to log the exception as Unicode on Python 2?
Sure, why not? Some exceptions may have unicode message with non-ASCII
characters. and we obviously can't cast such exceptio
On 05/15/2014 11:20 PM, Igor Kalnitsky wrote:
> Example:
>
> LOG.error(e.message)
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.
Christian.
--
Christian Berendt
Cloud Computing So
Hi,
> Is there a reason to log the exception as Unicode on Python 2?
Sure, why not? Some exceptions may have unicode message with non-ASCII
characters. and we obviously can't cast such exceptions with str() in
Python 2.x.
> The problem is that I don't know what is the best syntax to log
excepti
Hi,
I'm trying to define some rules to port OpenStack code to Python 3. I just
added a section in the "Port Python 2 code to Python 3" about formatting
exceptions and the logging module:
https://wiki.openstack.org/wiki/Python3#logging_module_and_format_exceptions
The problem is that I don't kno
19 matches
Mail list logo