diff --git a/doc/ChangeLog b/doc/ChangeLog index 9b2c79a..0903418 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2007-04-16 Jörgen Stenarson + * 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 * Changing binding for control-delete to forward_delete_word, adding tests to verify binding diff --git a/pyreadline/console/console.py b/pyreadline/console/console.py index 562dc21..9e88c36 100644 --- a/pyreadline/console/console.py +++ b/pyreadline/console/console.py @@ -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):