[issue1031213] Use correct encoding for printing SyntaxErrors
Guido van Rossum added the comment: In release25-maint, PyErr_Print() should be replaced with PyErr_Clear() also. Committed revision 58991. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
atsuo ishimoto added the comment: That's fine with me. Please replace PyErr_Print() with PyErr_Clear(). _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Guido van Rossum added the comment: atsuo ishimoto added the comment: That's fine with me. Please replace PyErr_Print() with PyErr_Clear(). Done. Committed revision 58471. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
atsuo ishimoto added the comment: Sorry for insufficient comment. When a codec raised an exception, I think the exception should be reported. Otherwise, user cannot know why Python prints broken line of code. Should we silently clear the exception raised by codecs, or print a message such as Codec raised an exception while processing compile error. ? _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Martin v. Löwis added the comment: Should we silently clear the exception raised by codecs, or print a message such as Codec raised an exception while processing compile error. ? Can you create a test case that triggers that specific problem? Regards, Martin _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
atsuo ishimoto added the comment: Codecs would hardly ever raises exception here. Usually, exception raised here would be a MemoryError. The unicode string we are trying to encode is just decoded by same codec. If codec raises exception other than MemoryError, the codec will likely have problem. I attached a script to print exception raised by codec. I wrote a buggy encoder, which never return string but raises an exception. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _import codecs def encoder(s, errors=strict): raise RuntimeError(dummy error) def decoder(s, errors=strict): return unicode(s, 'ascii', errors), len(s) def dmy_search(encoding): if encoding == dmyencoding: return (encoder, decoder, codecs.StreamWriter, codecs.StreamReader) def test(): codecs.register(dmy_search) src = #! -*- coding: dmyencoding -*-\n print 'hello compile(src, , exec) test() ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Guido van Rossum added the comment: There are tons of situations where such an exception will be suppressed, ofr better or for worse. I don't think this one deserves such a radical approach. On 10/11/07, atsuo ishimoto [EMAIL PROTECTED] wrote: atsuo ishimoto added the comment: Codecs would hardly ever raises exception here. Usually, exception raised here would be a MemoryError. The unicode string we are trying to encode is just decoded by same codec. If codec raises exception other than MemoryError, the codec will likely have problem. I attached a script to print exception raised by codec. I wrote a buggy encoder, which never return string but raises an exception. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Martin v. Löwis added the comment: ishimoto: in dec_utf8, there is a PyErr_Print call. What is the purpose of this call? _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Guido van Rossum added the comment: PyErr_Print() is called to report exception raised by codec. If PyUnicode_DecodeUTF8() or PyUnicode_AsEncodedString() return NULL, PyErr_Print() is called. This comment is not very helpful; it describes what happens, but not why, or whether that is a good idea. I believe that if this call is ever reached, two tracebacks will be printed, confusing the user. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
atsuo ishimoto added the comment: PyErr_Print() is called to report exception raised by codec. If PyUnicode_DecodeUTF8() or PyUnicode_AsEncodedString() return NULL, PyErr_Print() is called. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Martin v. Löwis added the comment: Thanks for the patch. It wouldn't work as-is, because it broke PGEN. I fixed that, and committed the change as r57961 and r57962. -- resolution: - accepted status: open - closed versions: +Python 2.5, Python 2.6 _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Guido van Rossum added the comment: We should make sure this is *not* merged into Py3k; there, things remain unicode until they're printed, at which point the only encoding that matters is the output file's encoding. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Changes by Georg Brandl: -- title: Patch for bug #780725 - Use correct encoding for printing SyntaxErrors _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com