curses module noutrefresh call fails when called on a pad object in pypy 2.3.1

Issue #1823 resolved
Tapani Kiiskinen
created an issue

I'm doing a noutrefresh call on a pad which i've instanciated with curses.newpad:

pad.noutrefresh(0, 0, y, x, y + rows - 1, x + cols - 1)

which fails with error:

File "/home/tappi/programs/pypy-2.3.1-linux64/lib_pypy/", line 840, in noutrefresh
return _check_ERR(lib.wnoutrefresh(self._win, *args),
TypeError: 'int(*)(WINDOW *)' expects 1 arguments, got 7

I checked the file and lib._m_ispad( returns false which results in wnoutrefresh being called instead of pnoutrefresh, where pnoutrefresh would be the right one to call when using pads.

The definition of _m_ispad depends on the existence of WINDOW_HAS_FLAGS definition:

int _m_ispad(WINDOW *win) {
  #if defined WINDOW_HAS_FLAGS
      return (win->_flags & _ISPAD);
      return 0;

If I hack this piece of code to not check for WINDOW_HAS_FLAGS my code works. Supposedly that variable should be defined somewhere but it's not being defined.

Context: the same code works with cpython.

I'm running an ubuntu 13.10 PyPy version: Python 2.7.6 (32f35069a16d, Jun 06 2014, 11:20:40) [PyPy 2.3.1 with GCC 4.6.3] on linux2

Comments (3)

  1. Tapani Kiiskinen reporter

    I have no idea if _ISPAD guarantees the existence of _flags in win but as far as the code working in the case that the flags do exist, then yes it does work for my code locally.

    (I'm also not sure if you're asking me but as more context I'm an outsider to this project.)

  2. Armin Rigo

    Looking more in the CPython source code for _cursesmodule.c, it seems that _flags and _ISPAD should always be present from <ncurses.h>. They may be missing from curses.h but PyPy never includes this. So I just removed the #ifdef logic in 71ab3dcb1309 and added a comment.

  3. Log in to comment