New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curses addch broken on Python3.3a1 #58431
Comments
The following code works on Python versions prior to 3.3a1: import curses
def test_screen(screen):
screen.addch(5,5, curses.ACS_HLINE)
screen.refresh()
curses.wrapper(test_screen) On python3.3, the program produces the following traceback: Traceback (most recent call last):
File "/tmp/p.py", line 7, in <module>
curses.wrapper(test_screen)
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/curses/__init__.py", line 94, in wrapper
return func(stdscr, *args, **kwds)
File "/tmp/p.py", line 4, in test_screen
screen.addch(5,5, curses.ACS_HLINE)
OverflowError: byte doesn't fit in chtype |
Marking as release blocker since this is a regression. Added people from the other curses issue as being likely to be interested in this one. |
New changeset 861a5f3e7453 by Victor Stinner in branch 'default': |
I introduced the arbitrary limit when I added support of the curses Unicode API (libncursesw). The limit is useless if libncursesw is used, whereas it blocks legal "characters" like KEY_xxx constants. So I just removed the check and it should not be ok. The real issue is that Python curses is not linked to libncursesw on Mac OS X! |
I'm reopening this bug because I've noticed that in Python3.3rc1, although trying to print curses.ACS_HLINE and other such characters no long cause an Exception, only blank characters are printed to the screen. Tested with both Terminal.App and xterm running under XQuartz. Here is some minimal test code, that will print a line on Python2.x but a blank screen on Python3.3rc1. |
import curses
def test_screen(screen):
screen.addch(5,5, curses.ACS_HLINE)
screen.addch(5,6, curses.ACS_HLINE)
screen.refresh()
curses.napms(2000)
curses.wrapper(test_screen) |
New changeset 27b5bd5f0e4c by Victor Stinner in branch 'default': |
If the Python curses module is compiled in Unicode mode (if curses.unget_wch() is present), addch(int) calls the C function wadd_wch() or mvwadd_wch(), instead of waddch() or mvwaddch(). It looks like the *_wch() family does not support characters like curses.ACS_HLINE. My commit fixes the issue. @Nicholas.Cole: Can you please try the last development version (default branch)? @georg.brandl: Can you please include the important fix 27b5bd5f0e4c in Python 3.3 final? |
(keep the issue open until the fix is included in Georg's repository) |
Unless I'm getting the build process wrong (possible, because I haven't tried testing fixes before), this fix isn't working for me. |
Oh did you compile Python? Did you install it? Do you have libncursesw? => do you have the function curses.unget_wch? What is the version of your libcurses[w] library? There are issues on libncurses 5.7. I think Ned Bat changed the script to compile Python on Mac to use a builtin copy of libncurses 5.9. See: |
Oh did you compile Python? Did you install it? Yes, I tried compiling it. #./configure MACOSX_DEPLOYMENT_TARGET=10.8 --enable-framework --with-universal-archs="64-bit" CFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" && make -j6 && make install Do you have libncursesw? => do you have the function curses.unget_wch? yes... Python 3.3.0rc1+ (default, Sep 3 2012, 09:45:35)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.57))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
>>> curses.unget_wch()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_curses.error: must call initscr() first
>>> curses.version
b'2.2'
>>> What is the version of your libcurses[w] library? There are issues on libncurses 5.7. I think Ned Bat changed the script to compile Python on Mac to use a builtin copy of libncurses 5.9. See: How do I check which version it was built against? The messages from ./configure just say that the tests pass, not which version it has found. |
On Linux, I use: $ ldd /usr/lib/python2.7/lib-dynload/_curses.so |grep curses
libncursesw.so.5 => /lib/i386-linux-gnu/libncursesw.so.5 (0xb76d0000)
$ ls -l /lib/i386-linux-gnu/libncursesw.so.5
lrwxrwxrwx 1 root root 18 nov. 18 2011
/lib/i386-linux-gnu/libncursesw.so.5 -> libncursesw.so.5.9 => version 5.9 |
On Mon, Sep 3, 2012 at 3:15 PM, STINNER Victor <report@bugs.python.org> wrote:
I get Version 5.4, which seems very out of date (I'm running the nicholas$ ls -l /usr/lib/libncurses. nicholas$ ldd /usr/lib/python2.7/lib-dynload/_curses.so |grep curses Can that possibly be right?? |
Yes. That's the version of ncurses that Apple ships with current versions of OS X. You can build it yourself and install into /usr/local and rebuild python. For ncurses 5.9, something like: ./configure --enable-widec --enable-shared --with-shared --without-normal should work. FWIW, when I run your test script with tip, I now do see the two horizontal bars. |
Done in d6d632f254ee. |
New changeset d6d632f254ee by Victor Stinner in branch 'default': |
I've just tried the OS X build of 3.3rc2, and this has been fixed. Thank you! |
Great! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: