Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r95017:f9e3e94e62d6 Date: 2018-08-22 07:37 +0200 http://bitbucket.org/pypy/pypy/changeset/f9e3e94e62d6/
Log: Test and fix on Windows (os.get_terminal_size() failures) diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py --- a/pypy/module/posix/interp_posix.py +++ b/pypy/module/posix/interp_posix.py @@ -2407,7 +2407,7 @@ if _WIN32: have_functions.append("HAVE_MS_WINDOWS") -def get_terminal_size(space, w_fd=None): +def _get_terminal_size(space, w_fd=None): if w_fd is None: fd = rfile.RFile(rfile.c_stdout(), close2=(None, None)).fileno() else: @@ -2447,7 +2447,13 @@ w_columns = space.newint(r_uint(winsize.c_ws_col)) w_lines = space.newint(r_uint(winsize.c_ws_row)) + return w_columns, w_lines +def get_terminal_size(space, w_fd=None): + try: + w_columns, w_lines = _get_terminal_size(space, w_fd) + except OSError as e: + raise wrap_oserror(space, e, eintr_retry=False) w_tuple = space.newtuple([w_columns, w_lines]) w_terminal_size = space.getattr(space.getbuiltinmodule(os.name), space.newtext('terminal_size')) diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py --- a/pypy/module/posix/test/test_posix2.py +++ b/pypy/module/posix/test/test_posix2.py @@ -1488,6 +1488,16 @@ raises(OSError, os.getxattr, self.path, 'user.test') assert os.listxattr(self.path, follow_symlinks=False) == init_names + def test_get_terminal_size(self): + os = self.posix + for args in [(), (1,), (0,), (42421,)]: + try: + w, h = os.get_terminal_size(*args) + except (ValueError, OSError): + continue + assert isinstance(w, int) + assert isinstance(h, int) + class AppTestEnvironment(object): def setup_class(cls): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit