Skip to content

Commit 81f7a65

Browse files
Add pyreadline3 backup import for readline (#1332)
* Add pyreadline3 backup import for readline `readline` is unavailable on Windows. Without this fix, the following error occurs when attempting to launch yewtube: ``` File "C:\Python313\Lib\site-packages\mps_youtube\commands\__init__.py", line 28, in command completer.add_cmd(command) ^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'add_cmd'``` * Fix readline import handling in main.py Handle ImportError for pyreadline3 and set has_readline flag. --------- Co-authored-by: Talha Asghar <[email protected]>
1 parent c32a2c4 commit 81f7a65

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mps_youtube/main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,23 @@
2929
from . import util
3030

3131
completer = None
32+
readline = None
3233
try:
3334
import readline
35+
except ImportError:
36+
try:
37+
from pyreadline3 import Readline
38+
readline = Readline()
39+
except ImportError:
40+
has_readline = False
41+
if readline:
3442
readline.set_history_length(2000)
3543
has_readline = True
3644
completer = util.CommandCompleter()
3745
readline.parse_and_bind('tab: complete')
3846
readline.set_completer(completer.complete_command)
3947
readline.set_completer_delims('')
4048

41-
except ImportError:
42-
has_readline = False
43-
4449
from . import g, c, commands, screen, history, init
4550
from . import __version__, playlists, content, listview
4651
from . import config

0 commit comments

Comments
 (0)