From 2c3f1de39b8b48bd6c5462aceefd112246eb07a7 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Mon, 12 Jul 2021 13:26:54 -0700 Subject: [PATCH] Handle pyreadline failure (Windows + Python 3.10+) Also, axe the explicit pyreadline fallback and dependency (as pyreadline is unmaintained). --- hy/completer.py | 14 ++++++++------ setup.py | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hy/completer.py b/hy/completer.py index 1d6ee1e21..ab2a1b46b 100644 --- a/hy/completer.py +++ b/hy/completer.py @@ -16,13 +16,15 @@ try: import readline -except ImportError: - try: - import pyreadline.rlmain - import pyreadline.unicode_helper # NOQA - import readline - except ImportError: +except AttributeError as e: + # https://github.com/hylang/hy/issues/2114 + # https://github.com/pyreadline/pyreadline/issues/65 + if "module 'collections' has no attribute 'Callable'" in str(e): docomplete = False + else: + raise +except ImportError: + docomplete = False if docomplete: if sys.platform == 'darwin' and 'libedit' in readline.__doc__: diff --git a/setup.py b/setup.py index 54e02a16c..0cca724c0 100755 --- a/setup.py +++ b/setup.py @@ -69,7 +69,6 @@ def run(self): 'funcparserlib>=0.3.6', 'colorama', 'astor>=0.8 ; python_version < "3.9"', - 'pyreadline>=2.1 ; os_name == "nt"', ], cmdclass=dict(install=Install), entry_points={