pyreadline: Fix crash when readline called from doctest. stdout was replaced by dummy object, we now assume encoding=="ascii" if stdout.encdoding is missing.

This commit is contained in:
jstenar
2007-04-16 17:56:36 +00:00
parent e25ea17ddb
commit d4f2cbeab8
2 changed files with 13 additions and 1 deletions
+6
View File
@@ -1,3 +1,9 @@
2007-04-16 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu>
* doctest imports pdb which imports readline, this means readline
can be imported when a dummy object has replaced stdout. The dummy
might miss the encoding property. We now assume stdout.encoding=="ascii"
in this case.
2007-04-14 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu>
* Changing binding for control-delete to forward_delete_word, adding tests to verify binding
+7 -1
View File
@@ -115,7 +115,13 @@ class CONSOLE_CURSOR_INFO(Structure):
_fields_ = [("dwSize", c_int),
("bVisible", c_byte)]
consolecodepage=sys.stdout.encoding
try:
consolecodepage=sys.stdout.encoding
except AttributeError: #This error occurs when pdb imports readline and doctest has replaced
#stdout with stdout collector
consolecodepage="ascii" #assume ascii codepage
def ensure_text(text):
"""helper to ensure that text passed to WriteConsoleA is ascii"""
if isinstance(text, unicode):