如何彻底卸载python中的readline模块?
我想通过完全摆脱它来动态禁用阅读线功能。不是通过禁用选项卡完成或任何其他提供的功能,而是通过完全解开免费资源。
我有一个程序,该程序将NCURS用于显示目的,但是返回到普通终端,您可以在其中将内容键入Python的Input()函数字段。除了终端调整和更新诅咒内部的终端大小和COLS变量外,一切都起作用。调整大小时会出现此可怕的错误:
c = stdscr.get_wch()
_curses.error: no input
最小的程序要复制:
import readline
import curses
def c_main(stdscr):
while True:
c = stdscr.get_wch()
stdscr.insstr(0, 0, repr(c))
curses.wrapper(c_main)
我尝试从sys.modules
中删除模块,摆脱了名称del readline
,垃圾收集,收集,收集,但这都是徒劳的。
print(readline.__file__)
给予:/usr/lib/python3.10/lib-dynload/readline.cpython-310-x86_64-linux-gnu.so
我想我知道我必须获得此文件的句柄不知何故,用CTYPE卸载它,但我不知道该怎么做。另外,有人可以指向我如何调和这两个库以使调整大小的工作的正确方向?谢谢。
I want to dynamically disable the readline functionality by completely getting rid of it. Not by disabling tab completion or any other provided functionality, but to completely unhook it, free resources.
I have a program that uses ncurses for display purposes, but returns to the normal terminal where you can type stuff into Python's input() function field. Everything works except for terminal resizing and updating the LINES and COLS variables inside curses. We are presented with this dreaded error upon resizing:
c = stdscr.get_wch()
_curses.error: no input
Minimal program to reproduce:
import readline
import curses
def c_main(stdscr):
while True:
c = stdscr.get_wch()
stdscr.insstr(0, 0, repr(c))
curses.wrapper(c_main)
I tried removing the module from sys.modules
, getting rid of the name del readline
, garbage collecting, but it is all futile.
print(readline.__file__)
gives: /usr/lib/python3.10/lib-dynload/readline.cpython-310-x86_64-linux-gnu.so
I think I understand that I have to obtain the handle for this file and somehow unload it with ctypes, but I have no idea how to do it. Alternatively, could someone point me in the right direction on how to reconcile these two libraries to make resizing work? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论