Can't print unicode chars in Python 2.5

Bug #527630 reported by Teobranton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DreamPie
Fix Released
Undecided
Unassigned

Bug Description

DreamPie 1.0
>>> u"čuňata"
0: u'\u010du\u0148ata'
>>> print u"čuňata"
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    print u"čuňata"
UnicodeEncodeError: 'ascii' codec can't encode character u'\u010d' in position 0: ordinal not in range(128)

Revision history for this message
Noam Yorav-Raphael (noamraph) wrote :

Thanks for the report!

Can you tell which operating system do you use, and copy the first few lines displayed when you start DreamPie?

Changed in dreampie:
status: New → Incomplete
Revision history for this message
Teobranton (teobran) wrote :

Python 2.5.2 (r252:60911, Jan 20 2010, 21:48:48)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "copyright", "credits" or "license()" for more information.
DreamPie 1.0
>>> print "here it is"
here it is

Revision history for this message
Noam Yorav-Raphael (noamraph) wrote :

The problem is that Python2.5 doesn't handle the PYTHONIOENCODING environment variable.
I added a hack in revision 134 that makes the subprocess import site.py only after it manually sets the output encoding. I hope this won't cause other problems.

summary: - UnicodeEncodeError in print
+ Can't print unicode chars in Python 2.5
Changed in dreampie:
status: Incomplete → Fix Committed
Revision history for this message
Teobranton (teobran) wrote :

Thank you for prompt update. I applied the patch and It works properly now.
Might be better set encoding from stdout?

getattr(sys.stdout, 'encoding', 'UTF-8')

otherwise OS what doesn't use UTF-8 will has a problem.

Revision history for this message
Noam Yorav-Raphael (noamraph) wrote : Re: [Bug 527630] Re: Can't print unicode chars in Python 2.5

No, it shouldn't be a problem since the output goes into the main
DreamPie process, which expects UTF-8.

Changed in dreampie:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.