From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RZSMh-0005jb-Sp for garchives@archives.gentoo.org; Sat, 10 Dec 2011 19:13:44 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AE24321C060; Sat, 10 Dec 2011 19:13:36 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 783A221C060 for ; Sat, 10 Dec 2011 19:13:36 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EFA8D64204 for ; Sat, 10 Dec 2011 19:13:35 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2098280042 for ; Sat, 10 Dec 2011 19:13:35 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <93c60fc277e37109a4ead36f69a6a50b7f72b229.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/output.py X-VCS-Directories: pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 93c60fc277e37109a4ead36f69a6a50b7f72b229 Date: Sat, 10 Dec 2011 19:13:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 39e07b9e-a50d-497d-9d5a-efeb214c768b X-Archives-Hash: 65a1e329f563b73f89f7e33a6f4d05e3 commit: 93c60fc277e37109a4ead36f69a6a50b7f72b229 Author: Zac Medico gentoo org> AuthorDate: Sat Dec 10 19:13:28 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Dec 10 19:13:28 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D93c60fc2 get_term_size: all values >=3D 0 for bug #394091 --- pym/portage/output.py | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pym/portage/output.py b/pym/portage/output.py index 6b10f7b..43d7503 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -422,12 +422,14 @@ class StyleWriter(formatter.DumbWriter): def get_term_size(): """ Get the number of lines and columns of the tty that is connected to - stdout. Returns a tuple of (lines, columns) or (-1, -1) if an error + stdout. Returns a tuple of (lines, columns) or (0, 0) if an error occurs. The curses module is used if available, otherwise the output of - `stty size` is parsed. + `stty size` is parsed. The lines and columns values are guaranteed to b= e + greater than or equal to zero, since a negative COLUMNS variable is + known to prevent some commands from working (see bug #394091). """ if not sys.stdout.isatty(): - return -1, -1 + return (0, 0) try: import curses try: @@ -442,10 +444,13 @@ def get_term_size(): out =3D out.split() if len(out) =3D=3D 2: try: - return int(out[0]), int(out[1]) + val =3D (int(out[0]), int(out[1])) except ValueError: pass - return -1, -1 + else: + if val[0] >=3D 0 and val[1] >=3D 0: + return val + return (0, 0) =20 def set_term_size(lines, columns, fd): """