commit: 36ba28f215223c9ea78c2f2eff771bb189b0f3c4
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Oct 14 07:34:13 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Oct 14 12:59:09 2025 +0000
URL:
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=36ba28f2
Work around python's pty module being unable to report its dimensions
Presently, portage sets up a pseudo-terminal by way of its
_create_pty_or_pipe() utility function. It makes use of Python's pty
module, which is unable to properly report its dimensions. Thus far,
those among the Python community that have recognised this issue appear
to have settled for the quintessentially pythonic approach of sweeping
it under the rug.
For the time being, have the _update_columns() function check whether
the shell appears to be a subprocess of portage and, if so, defer to the
existing value of the COLUMNS variable under the presumption that
portage has exported it. This is the very same 'solution' that is
employed by some of the bash functions that belong to portage.
See-also: 6f6440c538efb2edbcdfe298521252b6510a1a80
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
functions.sh | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/functions.sh b/functions.sh
index ba895df..4b25de7 100644
--- a/functions.sh
+++ b/functions.sh
@@ -873,7 +873,11 @@ _update_columns()
# may be gauged, albeit only in situations where doing so can be
# expected to work reliably.
# shellcheck disable=3028
- if _should_throttle 50; then
+ if from_portage; then
+ # Python's pty module is broken. For now, expect for
+ # portage to have exported COLUMNS to the environment.
+ set -- 0 "${COLUMNS}"
+ elif _should_throttle 50; then
test "${genfun_cols}"
return
elif [ "${genfun_bin_true}" ] && [ "$$" = "${BASHPID}" ]; then