Skip to content

Commit

Permalink
Merge from 2.3: Fix for issue #2452
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Jun 4, 2015
2 parents 641b927 + 50bfb46 commit df0b2ec
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions spyderlib/widgets/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
# pylint: disable=R0911
# pylint: disable=R0201

import keyword
import locale
import os
import time
import os.path as osp
import re
import sys
import keyword
import time

from spyderlib.qt.QtGui import (QMenu, QApplication, QToolTip, QKeySequence,
QMessageBox, QTextCursor, QTextCharFormat)
Expand All @@ -37,7 +38,7 @@
SaveHistoryMixin)
from spyderlib.widgets.arraybuilder import (SHORTCUT_INLINE, SHORTCUT_TABLE)
from spyderlib.py3compat import (is_text_string, to_text_string, builtins,
is_string)
is_string, PY3)


class ShellBaseWidget(ConsoleBaseWidget, SaveHistoryMixin):
Expand Down Expand Up @@ -592,7 +593,19 @@ def write(self, text, flush=False, error=False, prompt=False):

def flush(self, error=False, prompt=False):
"""Flush buffer, write text to console"""
text = "".join(self.__buffer)
# Fix for Issue 2452
if PY3:
try:
text = "".join(self.__buffer)
except TypeError:
text = b"".join(self.__buffer)
try:
text = text.decode( locale.getdefaultlocale()[1] )
except:
pass
else:
text = "".join(self.__buffer)

self.__buffer = []
self.insert_text(text, at_end=True, error=error, prompt=prompt)
QCoreApplication.processEvents()
Expand Down

0 comments on commit df0b2ec

Please sign in to comment.