From a3d1d1c2c8cccc842ed0f57e4696c127f22ddb5a 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). --- NEWS.rst | 2 ++ hy/completer.py | 13 +++++++------ setup.py | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index ae55572c4..8a5910ce3 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -9,10 +9,12 @@ Other Breaking Changes `(import [foo [bar]])` is now `(import foo [bar])` and `(import [foo :as baz])` is now `(import foo :as baz)`. To import all names from a module, use `(import foo *)`. +* Dropped support for `pyreadline` Bug Fixes ------------------------------ * Improved error messages for illegal uses of `finally` and `else`. +* Fixed a crash on Windows due to Readline 1.0a3 (released 2021-07-09) ============================== diff --git a/hy/completer.py b/hy/completer.py index 1d6ee1e21..bc3e6d739 100644 --- a/hy/completer.py +++ b/hy/completer.py @@ -16,13 +16,14 @@ 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/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={