Issue2596
Created on 2017-06-05.16:20:33 by tkohn, last changed 2017-06-10.13:27:23 by zyasoft.
msg11413 (view) |
Author: Tobias Kohn (tkohn) |
Date: 2017-06-05.16:20:32 |
|
If an exception's message contains linebreaks, they are output as "\n" instead of true linebreaks. This differs from how Python 2.7 behaves and breaks some of our error messages (i.e. makes them much less readable).
Example:
raise Exception("Hello\nWorld")
Expected Output:
Exception: Hello
World
Actual Output:
Exception: Hello\nWorld
I found the problem in Jython 2.7.1-rc2.
As far as I can tell, the cause for this behaviour is to be found in the method "asMessageString()" inside "Py.java" (line 1509).
|
msg11414 (view) |
Author: Stefan Richthofer (stefan.richthofer) |
Date: 2017-06-06.12:27:35 |
|
I can confirm this behaviour on Linux using Java 8.
@Jeff Maybe this broke due to the changes in
https://github.com/jythontools/jython/commit/f6b58bc3c202c8980f9664065cf1c62c9aa0c0a3#diff-3f5737cbd111ee102155501ebe449a1c
These didn't modify Py.asMessageString() though. Maybe some indirection causes this...? I feel like this should be fixed for the final release.
|
msg11415 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2017-06-06.16:58:05 |
|
Almost certainly I've overdone the defence against missing codecs. I'll take a look. Thanks for pointing out.
|
msg11417 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2017-06-07.08:24:47 |
|
I believe I've now fixed this. The defensive coding was a hang-over from problems I'd had when translating the exeption with a busted codec. This is dealt with by other means: I just didn't go back and rip this out.
With a cp936 console that won't encode Ç (C-cedilla), I now see:
>>> umsg = u"\c7a c'est\nune \xc9preuve"
>>> print umsg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Jeff\Documents\Eclipse\jython-trunk\h-故乡\d-分配\Lib\encodings\_java.py", line 89, in encode
_process_encode_errors(self.encoding, input, result, error_function, input_buffer, builder)
File "C:\Users\Jeff\Documents\Eclipse\jython-trunk\h-故乡\d-分配\Lib\encodings\_java.py", line 243, in _process_encode_errors
replacement, pos = error_function(e)
UnicodeEncodeError: 'ms936' codec can't encode character u'\xc9' in position 15: illegal multibyte sequence
>>> raise Exception(umsg)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception: \c7a c'est
une \xc9preuve
>>> raise Exception(umsg.encode('cp1252'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception: \c7a c'est
une \xc9preuve
>>>
Thus the line break is respected and I'm also defended against the encoding errors that motivated the original. This change is now in the trunk at: https://hg.python.org/jython/rev/c558ce4072ee
|
|
Date |
User |
Action |
Args |
2017-06-10 13:27:23 | zyasoft | set | status: pending -> closed resolution: accepted -> fixed |
2017-06-07 08:24:48 | jeff.allen | set | status: open -> pending resolution: accepted messages:
+ msg11417 |
2017-06-06 16:58:05 | jeff.allen | set | assignee: jeff.allen messages:
+ msg11415 |
2017-06-06 12:27:36 | stefan.richthofer | set | priority: urgent nosy:
+ jeff.allen, stefan.richthofer type: behaviour messages:
+ msg11414 |
2017-06-05 16:20:33 | tkohn | create | |
|