Hirokazu Yamamoto <[EMAIL PROTECTED]> added the comment:

Following dirty hack workarounds this bug. Comment of this function
says not ascii compatible encoding is not supported yet, (ie: UTF-16)
so probably this works.

Index: Parser/tokenizer.c
===================================================================
--- Parser/tokenizer.c  (revision 61632)
+++ Parser/tokenizer.c  (working copy)
@@ -464,6 +464,7 @@
        Py_XDECREF(tok->decoding_readline);
        readline = PyObject_GetAttrString(stream, "readline");
        tok->decoding_readline = readline;
+       tok->lineno = -1; /* dirty hack */
 
   cleanup:
        Py_XDECREF(stream);

But if multibyte character is in line like this, its line will not be
printed.

# coding: cp932
# 1
raise RuntimeError("あいうえお")
# 2

C:\Documents and Settings\WhiteRabbit>py3k cp932.py
Traceback (most recent call last):
  File "cp932.py", line 3, in <module>
    [22819 refs]

This is because Python/trackeback.c 's tb_displayline() assumes
input line is encoded with UTF-8. (simply using FILE structure +
Py_UniversalNewlineFgets)

# http://mail.python.org/pipermail/python-3000/2008-March/012546.html
# sounds nice, if we can replace all FILE structure to Python's own
# fast enough codeced Reader or something.

----------
type:  -> behavior

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2384>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to