bpython doesn't show output after utf-8 default encoding

Bug #633027 reported by Finn Årup Nielsen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bpython (Ubuntu)
Invalid
Undecided
Finn Årup Nielsen

Bug Description

Binary package hint: bpython

After "sys.setdefaultencoding('utf-8')" standard output to the terminal doesn't work. I have tried xterm and gnome-terminal. Example:

>>> print(1)
1
>>> import sys
>>> reload(sys)
>>> sys.setdefaultencoding('utf-8')
>>> print(2)
>>>

Here "2" is missing. I believe this behavior is a bug. In standard 'python' you will get:

>>> print(1)
1
>>> import sys
>>> reload(sys)
<module 'sys' (built-in)>
>>> sys.setdefaultencoding('utf-8')
>>> print(2)
2
>>>

Description: Ubuntu 10.04.1 LTS
Release: 10.04

bpython:
  Installeret: 0.9.5.2-2ubuntu1
  Kandidat: 0.9.5.2-2ubuntu1
  Versionstabel:
 *** 0.9.5.2-2ubuntu1 0
        500 http://dk.archive.ubuntu.com/ubuntu/ lucid/universe Packages
        100 /var/lib/dpkg/status

Revision history for this message
Andreas Stührk (trundle) wrote :

This has nothing to do with sys.setdefaultencoding(), it's because the sys module is reloaded. bpython sets sys.stdout, sys.stderr and sys.stdin to its own objects (needed because of the use of curses), but the reload of sys resets those attributes back to its original values.

I don't really agree that it is a bug. Either don't reload sys or save the values of sys.stdin, sys.stderr and sys.stdout and set them again after the reload.

Revision history for this message
Finn Årup Nielsen (fn) wrote :

Thanks, I see that it is not really a bug.

>>> import sys
>>> i, o, e = sys.stdin, sys.stdout, sys.stderr
>>> reload(sys)
>>> print(1)
>>> sys.stdout = o
>>> print(2)
2

I will change the status.

Revision history for this message
Finn Årup Nielsen (fn) wrote :

The issue can be regarded as not a bug since bpython sets the stdout.

Changed in bpython (Ubuntu):
assignee: nobody → Finn Årup Nielsen (fn)
status: New → Invalid
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.