[pypy-commit] pypy py3k_add_terminal_size: lib-python test passes for linux now at least.
marky1991
pypy.commits at gmail.com
Thu Aug 25 03:36:08 EDT 2016
Author: Mark Young <marky1991 at gmail.com>
Branch: py3k_add_terminal_size
Changeset: r86522:8befc19a63b8
Date: 2016-08-24 09:55 -0400
http://bitbucket.org/pypy/pypy/changeset/8befc19a63b8/
Log: lib-python test passes for linux now at least.
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -19,6 +19,7 @@
'statvfs_result': 'app_posix.statvfs_result',
'uname_result': 'app_posix.uname_result',
'urandom': 'app_posix.urandom',
+ 'terminal_size': 'app_posix.terminal_size'
}
if os.name == 'nt':
del appleveldefs['urandom'] # at interp on win32
diff --git a/pypy/module/posix/app_posix.py b/pypy/module/posix/app_posix.py
--- a/pypy/module/posix/app_posix.py
+++ b/pypy/module/posix/app_posix.py
@@ -92,6 +92,12 @@
version = structseqfield(3, "operating system version")
machine = structseqfield(4, "hardware identifier")
+class terminal_size(metaclass=structseqtype):
+
+ name = osname + ".terminal_size"
+
+ columns = structseqfield(0, "width of the terminal window in characters")
+ lines = structseqfield(1, "height of the terminal window in characters")
if osname == 'posix':
# POSIX: we want to check the file descriptor when fdopen() is called,
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
@@ -13,11 +13,13 @@
from rpython.rlib.objectmodel import specialize
from rpython.rlib.rarithmetic import r_longlong, intmask, r_uint
from rpython.rlib.unroll import unrolling_iterable
+from rpython.rtyper.lltypesystem import lltype
from rpython.tool.sourcetools import func_with_new_name
from pypy.interpreter.gateway import unwrap_spec, WrappedDefault, Unwrapper
from pypy.interpreter.error import (
- OperationError, oefmt, wrap_oserror, wrap_oserror2, strerror as _strerror)
+ OperationError, oefmt, wrap_oserror, wrap_oserror2, strerror as _strerror,
+ exception_from_saved_errno)
from pypy.interpreter.executioncontext import ExecutionContext
@@ -2179,7 +2181,7 @@
else:
# Assuming that all supported platforms will have ioctl at least
with lltype.scoped_alloc(rposix.WINSIZE) as winsize:
- failed = c_ioctl_voidp(fd, rposix.TIOCGWINSZ, winsize)
+ failed = rposix.c_ioctl_voidp(fd, rposix.TIOCGWINSZ, winsize)
if failed:
raise exception_from_saved_errno(space, space.w_OSError)
@@ -2187,4 +2189,8 @@
columns = space.wrap(winsize.c_ws_col)
lines = space.wrap(winsize.c_ws_row)
- return space.newtuple([columns, lines])
+ w_tuple = space.newtuple([columns, lines])
+ w_terminal_size = space.getattr(space.getbuiltinmodule(os.name),
+ space.wrap('terminal_size'))
+
+ return space.call_function(w_terminal_size, w_tuple)
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -637,6 +637,8 @@
macro=True, save_err=rffi.RFFI_FULL_ERRNO_ZERO)
c_closedir = external('closedir', [DIRP], rffi.INT, releasegil=False)
c_dirfd = external('dirfd', [DIRP], rffi.INT, releasegil=False)
+ c_ioctl_voidp = external('ioctl', [rffi.INT, rffi.UINT, rffi.VOIDP], rffi.INT,
+ save_err=rffi.RFFI_SAVE_ERRNO)
else:
dirent_config = {}
More information about the pypy-commit
mailing list