[issue2517] Error when printing an exception containing a Unicode string

2019-01-10 Thread Piotr Dobrogost
Piotr Dobrogost added the comment: Benjamin Peterson in comment https://bugs.python.org/issue2517#msg64771 wrote: "That is because Python encodes it's error messages as ASCII by default…" Could somebody please point where in the source code of Python 2 this happens? -- __

[issue2517] Error when printing an exception containing a Unicode string

2019-01-08 Thread Piotr Dobrogost
Change by Piotr Dobrogost : -- nosy: +piotr.dobrogost ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue2517] Error when printing an exception containing a Unicode string

2009-09-17 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue2517] Error when printing an exception containing a Unicode string

2008-07-08 Thread Nick Coghlan
Changes by Nick Coghlan <[EMAIL PROTECTED]>: -- resolution: -> fixed status: open -> closed ___ Python tracker <[EMAIL PROTECTED]> ___

[issue2517] Error when printing an exception containing a Unicode string

2008-07-08 Thread Nick Coghlan
Nick Coghlan <[EMAIL PROTECTED]> added the comment: Fixed in 64791. Blocked from being merged to Py3k (since there is no longer a __unicode__ special method). For MAL: the PyInstance_Check included in the patch for the benefit of classic classes defined in Python code also covers all of the cla

[issue2517] Error when printing an exception containing a Unicode string

2008-07-07 Thread Nick Coghlan
Nick Coghlan <[EMAIL PROTECTED]> added the comment: Adding this to my personal to-do list for the next beta release. -- assignee: georg.brandl -> ncoghlan priority: normal -> critical ___ Python tracker <[EMAIL PROTECTED]>

[issue2517] Error when printing an exception containing a Unicode string

2008-06-19 Thread Simon Cross
Simon Cross <[EMAIL PROTECTED]> added the comment: Justing prodding the issue again now that the betas are out. What's the next step? ___ Python tracker <[EMAIL PROTECTED]> ___

[issue2517] Error when printing an exception containing a Unicode string

2008-06-12 Thread Gabriel Genellina
Changes by Gabriel Genellina <[EMAIL PROTECTED]>: -- nosy: +gagenellina ___ Python tracker <[EMAIL PROTECTED]> ___ ___ Python-bugs-list

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Marc-Andre Lemburg
Marc-Andre Lemburg <[EMAIL PROTECTED]> added the comment: On 2008-06-11 16:49, Nick Coghlan wrote: > Nick Coghlan <[EMAIL PROTECTED]> added the comment: > > I'm not sure adding a dedicated method slot would be worth the hassle > involved - Py3k drop backs to just the tp_str slot anyway, and the

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Simon Cross
Simon Cross <[EMAIL PROTECTED]> added the comment: Re msg67974: > Minor cleanup of Simon's patch attached - aside from a couple of > unneeded whitespace changes, it all looks good to me. > > Not checking it in yet, since it isn't critical for this week's beta > release - I'd prefer to leave it un

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Nick Coghlan
Nick Coghlan <[EMAIL PROTECTED]> added the comment: I'm not sure adding a dedicated method slot would be worth the hassle involved - Py3k drop backs to just the tp_str slot anyway, and the only thing you gain with a tp_unicode slot over _PyType_Lookup of a __unicode__ attribute is a small reducti

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Marc-Andre Lemburg
Marc-Andre Lemburg <[EMAIL PROTECTED]> added the comment: On 2008-06-11 16:15, Nick Coghlan wrote: > Nick Coghlan <[EMAIL PROTECTED]> added the comment: > > Minor cleanup of Simon's patch attached - aside from a couple of > unneeded whitespace changes, it all looks good to me. > > Not checking

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Nick Coghlan
Nick Coghlan <[EMAIL PROTECTED]> added the comment: Minor cleanup of Simon's patch attached - aside from a couple of unneeded whitespace changes, it all looks good to me. Not checking it in yet, since it isn't critical for this week's beta release - I'd prefer to leave it until after that has be

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Simon Cross
Simon Cross <[EMAIL PROTECTED]> added the comment: Attached a patch which implements Nick Coghlan's suggestion. All existing tests in test_exceptions.py and test_unicode.py pass as does the new unicode(Exception(u"\xe1")) test. Added file: http://bugs.python.org/file10580/exception-unicode-with

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Nick Coghlan
Nick Coghlan <[EMAIL PROTECTED]> added the comment: Here's the key difference with the way PyObject_Format looks up the pseudo-slot method: PyObject *method = _PyType_Lookup(Py_TYPE(obj), str__format__); _PyType_Lookup instead of

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Marc-Andre Lemburg
Marc-Andre Lemburg <[EMAIL PROTECTED]> added the comment: On 2008-06-11 11:32, Nick Coghlan wrote: > Nick Coghlan <[EMAIL PROTECTED]> added the comment: > > As far as I am concerned, the implementation of PyObject_Unicode in > object.c has a bug in it: it should NEVER be retrieving __unicode__ f

[issue2517] Error when printing an exception containing a Unicode string

2008-06-11 Thread Nick Coghlan
Nick Coghlan <[EMAIL PROTECTED]> added the comment: As far as I am concerned, the implementation of PyObject_Unicode in object.c has a bug in it: it should NEVER be retrieving __unicode__ from the instance object. The implementation of PyObject_Format in abstract.c shows the correct way to retrie

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: On Mon, Jun 9, 2008 at 2:04 PM, David Fraser <[EMAIL PROTECTED]> wrote: > > David Fraser <[EMAIL PROTECTED]> added the comment: > > So I've got a follow-up patch that adds tp_unicode. > Caveat that I've never done anything like this before

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread David Fraser
David Fraser <[EMAIL PROTECTED]> added the comment: So I've got a follow-up patch that adds tp_unicode. Caveat that I've never done anything like this before and it's almost certain to be wrong. It does however generate the desired result in this case :-) Added file: http://bugs.python.org/file

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Marc-Andre Lemburg
Marc-Andre Lemburg <[EMAIL PROTECTED]> added the comment: Removing 3.0 from the versions list. -- nosy: +lemburg versions: -Python 3.0 ___ Python tracker <[EMAIL PROTECTED]> ___ _

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Simon Cross
Simon Cross <[EMAIL PROTECTED]> added the comment: Benjamin Peterson wrote: > What version are you using? In Py3k, str is unicode so __str__ can > return a unicode string. I'm sorry it wasn't clear. I'm aware that this issue doesn't apply to Python 3.0. I'm testing on both Python 2.5 and Python

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Simon Cross
Simon Cross <[EMAIL PROTECTED]> added the comment: Concerning http://bugs.python.org/issue1551432: I'd much rather have working unicode(e) than working unicode(Exception). Calling unicode(C) on any class C which overrides __unicode__ is broken without tp_unicode anyway.

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: On Mon, Jun 9, 2008 at 8:40 AM, Simon Cross <[EMAIL PROTECTED]> wrote: > > Simon Cross <[EMAIL PROTECTED]> added the comment: > > One of the examples Christoph tried was > > unicode(Exception(u'\xe1')) > > which fails quite oddly with: > >

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread David Fraser
David Fraser <[EMAIL PROTECTED]> added the comment: Aha - the __unicode__ method was previously there in Python 2.5, and was ripped out because of the unicode(Exception) problem. See http://bugs.python.org/issue1551432. The reversion is in http://svn.python.org/view/python/trunk/Objects/exceptio

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread David Fraser
Changes by David Fraser <[EMAIL PROTECTED]>: -- nosy: +davidfraser ___ Python tracker <[EMAIL PROTECTED]> ___ ___ Python-bugs-list maili

[issue2517] Error when printing an exception containing a Unicode string

2008-06-09 Thread Simon Cross
Simon Cross <[EMAIL PROTECTED]> added the comment: One of the examples Christoph tried was unicode(Exception(u'\xe1')) which fails quite oddly with: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128) The reason for this is Exception l

[issue2517] Error when printing an exception containing a Unicode string

2008-04-02 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: We can't do much about that because only security fixes are backported to version < 2.5. __ Tracker <[EMAIL PROTECTED]> __ _

[issue2517] Error when printing an exception containing a Unicode string

2008-04-02 Thread Christoph Burgmer
Christoph Burgmer <[EMAIL PROTECTED]> added the comment: JFTR: > print unicode(e.message).encode("utf-8") only works for Python 2.5, not downwards. __ Tracker <[EMAIL PROTECTED]> __ ___

[issue2517] Error when printing an exception containing a Unicode string

2008-04-01 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: Have you looked at PyErr_Display? There are many, many possible exceptions, and it ignores them all because "too many callers rely on this." So, I think all we can do is warn. I will look into encoding the message differently.

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: Shouldn't it be an exception rather than a warning? The fact that an exception can be downgraded to a warning (and thus involuntarily silenced) is a bit disturbing IMHO. Another possibility would be to display the warning, and *then* to encod

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: After thinking some more, I'm going to add 2.6 to this. I'm attaching a patch for the trunk (it can be merged in Py3k, and maybe 2.5) which displays a UnicodeWarning when an Exception cannot be displayed due to encoding issues. Georg, can

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Even in 2.5, __str__ is allowed to return a Unicode object; we could change BaseException_str this way: Index: exceptions.c === --- exceptions.c(revision 61957) +++

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: >I never believed Python to be a programming language with good Unicode >integration. Several points were missing that would've been nice or >even essential to have for good development with Unicode, most ignored >for the sake of maintai

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Christoph Burgmer
Christoph Burgmer <[EMAIL PROTECTED]> added the comment: Though I welcome the reopening of the bug for Python 3.0 I must say that plans of not fixing a core element rather surprises me. I never believed Python to be a programming language with good Unicode integration. Several points were miss

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: I am going to reopen this issue for Py3k. The recommended encoding for Python source files in 2.x is ASCII; I wouldn't say correctly dealing with non-ASCII exceptions is fully supported. In 3.x, however, the recommended encoding is UTF-8, s

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Note the interpreter cannot print the exception either: >>> raise Exception(u'Error when printing ü') Traceback (most recent call last): File "", line 1, in Exception>>> -- nosy: +amaury.forgeotdarc

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Christoph Burgmer
Christoph Burgmer <[EMAIL PROTECTED]> added the comment: Thanks, this does work. But, where can I find the piece of information you just gave to me in the docs? I couldn't find any interface definition for Exceptions. Further more will this be regarded as a bug? >From [1] I understand that "un

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: Use: print unicode(e.message).encode("utf-8") __ Tracker <[EMAIL PROTECTED]> __ ___ Python-bugs-

[issue2517] Error when printing an exception containing a Unicode string

2008-03-31 Thread Christoph Burgmer
Christoph Burgmer <[EMAIL PROTECTED]> added the comment: To be more precise: I see no way to convert the encapsulated non-ASCII data from the string in an easy way. Taking e from my last post none of the following will work: str(e) # UnicodeDecodeError e.__str__() # UnicodeDecodeError e.__unicod

[issue2517] Error when printing an exception containing a Unicode string

2008-03-30 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: That is because Python encodes it's error messages as ASCII by default, and "ü" is not in ASCII. You can fix this by using "print unicode_msg.encode("utf-8")" or something similar. -- nosy: +benjamin.peterson resolution: -> invali

[issue2517] Error when printing an exception containing a Unicode string

2008-03-30 Thread Christoph Burgmer
New submission from Christoph Burgmer <[EMAIL PROTECTED]>: Python seems to have problems when an exception is thrown that contains non-ASCII text as a message and is converted to a string. >>> try: ... raise Exception(u'Error when printing ü') ... except Exception, e: ... print e ... Tr