I'm not able to run fileobj on a recent 14.1-STABLE system. $ uname -a FreeBSD dwarf 14.1-STABLE FreeBSD 14.1-STABLE #17 stable/14-n268102-6b1f530935c: Fri Jul 12 09:41:20 PDT 2024 root@dwarf:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 $ pkg info -I fileobj fileobj-0.8.6_1 Portable hex editor with vi like interface $ fileobj Traceback (most recent call last): File "/usr/local/bin/fileobj", line 29, in <module> import fileobj.core File "/usr/local/lib/python3.11/site-packages/fileobj/core.py", line 30, in <module> from . import allocator File "/usr/local/lib/python3.11/site-packages/fileobj/allocator.py", line 24, in <module> from . import fileobj File "/usr/local/lib/python3.11/site-packages/fileobj/fileobj.py", line 34, in <module> from . import screen File "/usr/local/lib/python3.11/site-packages/fileobj/screen.py", line 33, in <module> from . import ncurses as _screen File "/usr/local/lib/python3.11/site-packages/fileobj/ncurses.py", line 29, in <module> from . import kbd File "/usr/local/lib/python3.11/site-packages/fileobj/kbd.py", line 47, in <module> _KEY_RESIZE = curses.KEY_RESIZE ^^^^^^^^^^^^^^^^^ AttributeError: module 'curses' has no attribute 'KEY_RESIZE'. Did you mean: 'KEY_RESUME'? It looks like the curses in the python port is missing the KEY_RESIZE attribute. Other KEY_ attributes are available though. $ pkg info -Ix ^python python-3.11_3,2 "meta-port" for the default version of Python interpreter python3-3_4 Meta-port for the Python interpreter 3.x python311-3.11.9_1 Interpreted object-oriented programming language $ python Python 3.11.9 (main, Jul 9 2024, 16:57:46) [Clang 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15 on freebsd14 Type "help", "copyright", "credits" or "license" for more information. >>> import curses >>> curses.KEY_RESIZE Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'curses' has no attribute 'KEY_RESIZE'. Did you mean: 'KEY_RESUME'? >>> curses.KEY_F1 265 >>>
Maintainer informed via mail
This looks like an issue related to the latest ncurses (v6.5) import since this used to work with 14-STABLE and still does on 13.3-RELEASE-p6. I think this issue belongs to base, but I am hesitant to move it over as I am only an alumni. :) When Python is built, is relies upon keyname() to determine which KEY_* variables to incorporate. Previously, keyname() would return KEY_RESIZE when the terminal was resized, but now, it returns NULL. This is point where Python makes the determination. If keyname() returns a NULL, then the KEY will not be included. https://github.com/python/cpython/blob/v3.11.10/Modules/_cursesmodule.c#L4908 I did not dive into ncurses code much, but this has mention of KEY_RESIZE: https://invisible-island.net/ncurses/NEWS.html#t20240120 Here is a simple program to show what keyname() can return: #include <ncurses.h> int main(void) { int ch; initscr(); cbreak(); noecho(); printw("KEY_RESIZE: %s\n", keyname(KEY_RESIZE)); while ((ch = getch()) != ERR) { printw("Got: %s\n", keyname(ch)); refresh(); } return (endwin()); }
CC bapt for ncurses 6.5 importing.
Hello, this may fix your problem. Can you give it a try? https://reviews.freebsd.org/D47153. I have tested on ranger and it works again.
(In reply to SHENG-YI HUNG from comment #4) Thank you! That did fix both fileobj and that sample program.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=514f4e89acd2e7b1824b261055bef49a3da6a956 commit 514f4e89acd2e7b1824b261055bef49a3da6a956 Author: SHENG-YI HONG <aokblast@FreeBSD.org> AuthorDate: 2024-10-23 20:38:33 +0000 Commit: Li-Wen Hsu <lwhsu@FreeBSD.org> CommitDate: 2024-10-23 20:39:36 +0000 ncurses: Fix codegen for key names and codes Adding back arguments, which were missed during the import of ncurses version 6.5, to the code gen awk script. This is modified from lib_keyname.c and keys.list targets in contrib/ncurses/ncurses/Makefile.in of 21817992b3314c908ab50f0bb88d2ee750b9c4ac PR: 280697 Reported by: np Reviewed by: bapt Tested by: scf Fixes: 21817992b331 ncurses: vendor import version 6.5 MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47153 lib/ncurses/tinfo/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1e4603b7a8193064a9879c6c1906be1c7cb57575 commit 1e4603b7a8193064a9879c6c1906be1c7cb57575 Author: SHENG-YI HONG <aokblast@FreeBSD.org> AuthorDate: 2024-10-23 20:38:33 +0000 Commit: Li-Wen Hsu <lwhsu@FreeBSD.org> CommitDate: 2024-10-30 00:53:05 +0000 ncurses: Fix codegen for key names and codes Adding back arguments, which were missed during the import of ncurses version 6.5, to the code gen awk script. This is modified from lib_keyname.c and keys.list targets in contrib/ncurses/ncurses/Makefile.in of 21817992b3314c908ab50f0bb88d2ee750b9c4ac PR: 280697 Reported by: np Reviewed by: bapt Tested by: scf Fixes: 21817992b331 ncurses: vendor import version 6.5 MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47153 (cherry picked from commit 514f4e89acd2e7b1824b261055bef49a3da6a956) lib/ncurses/tinfo/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)