From a0079df625bbfc8e20e57dfc1ff1f3d098a077d4 Mon Sep 17 00:00:00 2001 From: mattip Date: Wed, 24 Mar 2021 13:59:18 +0200 Subject: [PATCH 1/2] try importing built-in module first --- pyrepl/curses.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyrepl/curses.py b/pyrepl/curses.py index 0331ce0..934fe6e 100644 --- a/pyrepl/curses.py +++ b/pyrepl/curses.py @@ -1,4 +1,4 @@ - +from __future__ import absolute_import # Copyright 2000-2010 Michael Hudson-Doyle # Armin Rigo # @@ -19,5 +19,8 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from ._minimal_curses import setupterm, tigetstr, tparm, error +# First try the built-in module +try: + from _minimal_curses import setupterm, tigetstr, tparm, error +except ImportError: + from ._minimal_curses import setupterm, tigetstr, tparm, error From 490d6382d9ad8d993310492bc61aee3855269549 Mon Sep 17 00:00:00 2001 From: mattip Date: Thu, 25 Mar 2021 15:51:16 +0200 Subject: [PATCH 2/2] fix another import --- testing/test_curses.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testing/test_curses.py b/testing/test_curses.py index 5188f43..a4776b5 100644 --- a/testing/test_curses.py +++ b/testing/test_curses.py @@ -1,5 +1,8 @@ import pytest -from pyrepl.curses import setupterm +try: + from pyrepl.curses import setupterm, error as curses_error +except ImportError: + pytest.skip('cannot import curses', allow_module_level=True) import pyrepl @@ -17,7 +20,7 @@ def test_setupterm(monkeypatch): monkeypatch.delenv('TERM') with pytest.raises( - pyrepl._minimal_curses.error, + curses_error, match=r"setupterm\(None, 0\) failed \(err=-1\)", ): setupterm(None, 0)