nyx icon indicating copy to clipboard operation
nyx copied to clipboard

Nyx incompatible with Python 3.11+ (getargspec error)

Open Rijndael1998 opened this issue 1 year ago • 4 comments

When you run nyx and then scroll on any page, it crashes.

Log:

Traceback (most recent call last):
  File "/usr/bin/nyx", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/nyx/__init__.py", line 176, in main
    nyx.starter.main()
  File "/usr/lib/python3.11/site-packages/stem/util/conf.py", line 289, in wrapped
    return func(*args, config = config, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nyx/starter.py", line 128, in main
    nyx.curses.start(nyx.draw_loop, acs_support = config.get('acs_support', True), transparent_background = True, cursor = False)
  File "/usr/lib/python3.11/site-packages/nyx/curses.py", line 219, in start
    curses.wrapper(_wrapper)
  File "/usr/lib/python3.11/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nyx/curses.py", line 217, in _wrapper
    function()
  File "/usr/lib/python3.11/site-packages/nyx/__init__.py", line 243, in draw_loop
    keybinding.handle(key)
  File "/usr/lib/python3.11/site-packages/nyx/panel/__init__.py", line 81, in handle
    if inspect.getargspec(self._action).args == ['key']:
       ^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?

Rijndael1998 avatar May 19 '23 19:05 Rijndael1998

Thanks Rijndael! The issue is that Python 3.11 removed the inspect.getargspec() function which broke our compatibility with it.

I left Tor a couple years ago. Nyx is presently unmaintained so this is unlikely to be fixed. If the project gets a new maintainer this should be relatively easy to correct.

atagar avatar May 19 '23 19:05 atagar

Here is a quick fix until new nyx version is out: Just replace all inspect.getargspec() with inspect.getfullargspec()

Have installed nyx and run this command as sudo: find /usr/lib/python3.11/site-packages/nyx -type f -exec sed -i 's/getargspec/getfullargspec/g' {} \; It will do replacement on all files automatically.

Note that python version in command (/usr/lib/python3.11/) will change in future.

mzivic7 avatar May 22 '23 14:05 mzivic7

If installed from an apt repository (ubuntu/debian) it is located in /usr/local/bin/nyx.

sed -i 's/getargspec/getfullargspec/g' /usr/local/bin/nyx
find /usr/local/lib/python3.11/dist-packages/nyx -type f -exec sed -i 's/getargspec/getfullargspec/g' {} \;

is the debian version of patch by @mzivic7

I am willing to take over the maintenance of nyx

edit: On latest debian, this error makes nyx crash at startup.

0ire avatar Jul 19 '23 14:07 0ire

I am on arch linux, and have no debian-based linux to test, i had no idea that pacman installs nyx to different directory.

So, for debian-based, patch is: find /usr/local/bin/nyx -type f -exec sed -i 's/getargspec/getfullargspec/g' {} \;

Anyway in this commit to nyx, this bug is fixed, just someone needs to release new version.

mzivic7 avatar Jul 23 '23 14:07 mzivic7