mirror of
https://github.com/wassname/pyreadline.git
synced 2026-09-10 12:20:43 +08:00
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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user