Author: Matti Picus <matti.pi...@gmail.com> Branch: py3.6 Changeset: r98586:aefd6cf46eed Date: 2020-01-26 08:37 +0200 http://bitbucket.org/pypy/pypy/changeset/aefd6cf46eed/
Log: merge default into branch diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py --- a/lib_pypy/_curses.py +++ b/lib_pypy/_curses.py @@ -57,7 +57,7 @@ if key_n == b"UNKNOWN KEY": continue if not isinstance(key_n, str): # python 3 - key_n = key_n.decode() + key_n = key_n.decode('utf-8') key_n = key_n.replace('(', '').replace(')', '') globals()[key_n] = key @@ -83,7 +83,9 @@ def _ensure_initialised_color(): - if not _initialised and _initialised_color: + if not _initialised: + raise error("must call initscr() first") + if not _initialised_color: raise error("must call start_color() first") @@ -434,11 +436,16 @@ val = lib.keyname(val) if val == ffi.NULL: return "" - return ffi.string(val) + key_n = ffi.string(val) + if not isinstance(key_n, str): + key_n = key_n.decode('utf-8') + return key_n @_argspec(0, 1, 2) def getstr(self, y, x, n=1023): n = min(n, 1023) + if n < 0: + raise ValueError("'n' must be nonnegative") buf = ffi.new("char[1024]") # /* This should be big enough.. I hope */ if y is None: @@ -481,6 +488,8 @@ @_argspec(0, 1, 2) def instr(self, y, x, n=1023): n = min(n, 1023) + if n < 0: + raise ValueError("'n' must be nonnegative") buf = ffi.new("char[1024]") # /* This should be big enough.. I hope */ if y is None: code = lib.winnstr(self._win, buf, n) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit