From c21140cf8561c8852f1527a1e0f4666ce5732220 Mon Sep 17 00:00:00 2001 From: ndparker Date: Sun, 16 Nov 2014 15:33:53 +0100 Subject: [PATCH] add pypy3 support --- _setup/py3/setup.py | 10 +++++----- _setup/py3/term/_term.py | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/_setup/py3/setup.py b/_setup/py3/setup.py index 83f1c21..a759e16 100644 --- a/_setup/py3/setup.py +++ b/_setup/py3/setup.py @@ -41,7 +41,7 @@ def check_python_version(impl, version_min, version_max): """ Check python version """ if impl == 'python': version_info = _sys.version_info - elif impl == 'pypy': + elif impl == 'pypy3': version_info = getattr(_sys, 'pypy_version_info', None) if not version_info: return @@ -50,7 +50,7 @@ def check_python_version(impl, version_min, version_max): return version_info = _sys.version_info else: - raise AssertionError("impl not in ('python', 'pypy', 'jython')") + raise AssertionError("impl not in ('python', 'pypy3', 'jython')") pyversion = list(map(int, version_info[:3])) if version_min: @@ -344,9 +344,9 @@ def run(config=('package.cfg',), ext=None, script_args=None, manifest_only=0): python_min = pkg.get('python.min') or None python_max = pkg.get('python.max') or None check_python_version('python', python_min, python_max) - pypy_min = pkg.get('pypy.min') or None - pypy_max = pkg.get('pypy.max') or None - check_python_version('pypy', pypy_min, pypy_max) + pypy_min = pkg.get('pypy3.min') or None + pypy_max = pkg.get('pypy3.max') or None + check_python_version('pypy3', pypy_min, pypy_max) jython_min = pkg.get('jython.min') or None jython_max = pkg.get('jython.max') or None check_python_version('jython', jython_min, jython_max) diff --git a/_setup/py3/term/_term.py b/_setup/py3/term/_term.py index b94f58e..4d70d1e 100644 --- a/_setup/py3/term/_term.py +++ b/_setup/py3/term/_term.py @@ -50,21 +50,28 @@ class _INFO(dict): except (TypeError, _curses.error): pass else: + try: + _curses.tigetstr('sgr0') + except TypeError: # pypy3 + bc = lambda val: val.encode('ascii') + else: + bc = lambda val: val + def make_color(color): """ Make color control string """ - seq = _curses.tigetstr('setaf').decode('ascii') + seq = _curses.tigetstr(bc('setaf')).decode('ascii') if seq is not None: # XXX may fail - need better logic seq = seq.replace("%p1", "") % color return seq - self['NORMAL'] = _curses.tigetstr('sgr0').decode('ascii') - self['BOLD'] = _curses.tigetstr('bold').decode('ascii') + self['NORMAL'] = _curses.tigetstr(bc('sgr0')).decode('ascii') + self['BOLD'] = _curses.tigetstr(bc('bold')).decode('ascii') - erase = _curses.tigetstr('el1').decode('ascii') + erase = _curses.tigetstr(bc('el1')).decode('ascii') if erase is not None: self['ERASE'] = erase + \ - _curses.tigetstr('cr').decode('ascii') + _curses.tigetstr(bc('cr')).decode('ascii') self['RED'] = make_color(_curses.COLOR_RED) self['YELLOW'] = make_color(_curses.COLOR_YELLOW)