[ python-Bugs-1708316 ] doctest work with Windows PyReadline

SourceForge.net noreply at sourceforge.net
Thu Apr 26 21:02:04 CEST 2007


Bugs item #1708316, was opened at 2007-04-26 12:02
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1708316&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: manuelg (manuelg_)
Assigned to: Nobody/Anonymous (nobody)
Summary: doctest work with Windows PyReadline

Initial Comment:
doctest crashes when working with Windows PyReadline (PyReadline is a component of Windows IPython)

PyReadline expects "_SpoofOut" to have an "encoding" attribute

E
======================================================================
ERROR: testDocTest (__main__.TestDocTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_freecell_solver.py", line 26, in testDocTest
    r = doctest.testmod(freecell_solver)
  File "c:\Python25\Lib\doctest.py", line 1799, in testmod
    runner.run(test)
  File "c:\Python25\Lib\doctest.py", line 1335, in run
    self.debugger = _OutputRedirectingPdb(save_stdout)
  File "c:\Python25\Lib\doctest.py", line 320, in __init__
    pdb.Pdb.__init__(self, stdout=out)
  File "c:\Python25\Lib\pdb.py", line 66, in __init__
    import readline
  File "C:\Python25\Lib\site-packages\readline.py", line 5, in <module>
    from pyreadline import *
  File "C:\Python25\Lib\site-packages\pyreadline\__init__.py", line 10, in <module>
    from rlmain import *
  File "C:\Python25\Lib\site-packages\pyreadline\rlmain.py", line 13, in <module>
    import clipboard,logger,console
  File "C:\Python25\Lib\site-packages\pyreadline\console\__init__.py", line 14,in <module>
    from console import *
  File "C:\Python25\Lib\site-packages\pyreadline\console\console.py", line 118,in <module>
    consolecodepage=sys.stdout.encoding
AttributeError: _SpoofOut instance has no attribute 'encoding'

This is an easy fix with 2 lines of code to doctest.py

right after doctest.py imports "sys", store the "sys.stdout.encoding"

_sys_stdout_encoding = sys.stdout.encoding

Then add this as an attribute "encoding" in the "_SpoofOut" class

# Override some StringIO methods.
class _SpoofOut(StringIO):

    ....
            
    encoding = _sys_stdout_encoding



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1708316&group_id=5470


More information about the Python-bugs-list mailing list