pypy3.6 7.3.0 curses get_wch: ffi.error: undefined type name wint_t[1]

Create issue
Issue #3144 resolved
Anthony Sottile created an issue

Still reproduces on the latest nightly – seems to be a regression (I was able to call this function previously, it just misbehaved)

$ ./pypy-c-jit-98442-def680385695-linux64/bin/pypy3 ../t.py 
Traceback (most recent call last):
  File "../t.py", line 6, in <module>
    curses.wrapper(c_main)
  File "/home/asottile/workspace/babi/x/pypy-c-jit-98442-def680385695-linux64/lib-python/3/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "../t.py", line 4, in c_main
    stdscr.get_wch()
  File "/home/asottile/workspace/babi/x/pypy-c-jit-98442-def680385695-linux64/lib_pypy/_curses.py", line 407, in get_wch
    wch = ffi.new("wint_t[1]")
ffi.error: undefined type name
wint_t[1]
^

import curses

def c_main(stdscr):
    stdscr.get_wch()

curses.wrapper(c_main)

In case it matters, here is my curses versions:

$ dpkg -l | grep libncurses
ii  libncurses5:amd64                          6.1-1ubuntu1.18.04                              amd64        shared libraries for terminal handling
ii  libncursesw5:amd64                         6.1-1ubuntu1.18.04                              amd64        shared libraries for terminal handling (wide character support)
ii  libncursesw5-dev:amd64                     6.1-1ubuntu1.18.04                              amd64        developer's libraries for ncursesw

Comments (5)

  1. mattip

    yeah, it seemed I regressed this when making the linux packages portable. You should be able to rebuild the curses cffi module by running

    pypy3 _curses_build.py
    

    in the lib_pypy directory. In parallel, I will try to see how to fix this

  2. mattip

    The problem seemed to be the build script was checking ncurses version when it should have been checking which of ncurses/ncursesw is being used. Fixed in 580ac8d8c1af, the essence of which is

    diff -r 11fe1f50f3f8 -r 580ac8d8c1af lib_pypy/_curses_build.py
    --- a/lib_pypy/_curses_build.py Thu Jan 09 14:59:46 2020 +0000
    +++ b/lib_pypy/_curses_build.py Fri Jan 10 10:44:14 2020 +0800
    @@ -385,7 +383,7 @@
     void _m_getsyx(int *yx);
     """)
    
    -if version > (5, 7):
    +if 'ncursesw' in libs:
         ffi.cdef("""
     typedef int... wint_t;
     int wget_wch(WINDOW *, wint_t *);
    

    and after that rebuilding the _curses c-extension module

  3. Log in to comment