Message1933
Running following code fails when using Jython 2.2.1 rc 1 but succeeds with Jython 2.2 (and earlier alphas/betas/rcs) and Python 2.3/2.4/2.5.
- - - - - - - - - -
import sys
from StringIO import StringIO
msg = u'Circle is 360\u00B0'
sys.stdout = StringIO()
print msg
assert sys.stdout.getvalue() == msg + '\n'
- - - - - - - - - -
The traceback is below the code and shows that printing a unicode string fails even though in this case stdout has been intercepted.
- - - - - - - - - -
Traceback (innermost last):
File "unictest.py", line 7, in ?
UnicodeError: ascii encoding error: ordinal not in range(128)
- - - - - - - - - -
Being able to print unicode strings like this is crucial in our case. We've been implementing a test automation framework that runs on Python and Jython and it can be extended using so called test libraries which they can write messages to a common test log simply by writing to stdout. This way the API between the framework and libraries is pretty simple and it works the same way both when a lib is written in Python and when it's written in Java (we intercept java.lang.System.out too).
|
|
Date |
User |
Action |
Args |
2008-02-20 17:18:03 | admin | link | issue1802339 messages |
2008-02-20 17:18:03 | admin | create | |
|