Ipython Ctypes conflict

Wanderer wanderer at dialup4less.com
Thu Feb 10 20:57:46 CET 2011


When I try to use program that uses ctypes to load a dll in Ipython. I
get

Traceback (most recent call last):
    File "... \console.py" line 671, in hook_wrapper_23
    res = ensire_str(readline_hook(prompt))
    File "...\rlmain.py", lin 342, in readline
    return self.mode.readline(prompt)
    File "...\emac.py", line 116, in readline
    self._print_prompt()
    File "...\rlmain.py, line 298, in _print_prompt
    n = c.write_scrolling(self.prompt, self.prompt_color)
    File "...\console.py", line 289, in write_scrolling
    w, h = self.size()
TypeError: 'NoneType' object is not iterable
Readline internal error

Some hacking in console.py shows it is caused by

    def size(self, width=None, height=None):
        u'''Set/get window size.'''
        info = CONSOLE_SCREEN_BUFFER_INFO()
        status = self.GetConsoleScreenBufferInfo(self.hout,
byref(info))
        if not status:
            return None
        if width is not None and height is not None:
            wmin = info.srWindow.Right - info.srWindow.Left + 1
            hmin = info.srWindow.Bottom - info.srWindow.Top + 1
            #print wmin, hmin
            width = max(width, wmin)
            height = max(height, hmin)
            #print width, height
            self.SetConsoleScreenBufferSize(self.hout,
                                            self.fixcoord(width,
height))
        else:
            return (info.dwSize.X, info.dwSize.Y)

After loading the dll, GetConsoleScreenBufferInfo always returns zero,
so size returns None and everybody is unhappy.

I don't get the problem in Idle or WinPython.




More information about the Python-list mailing list