From c1fcfae70f7bff5ea5642414e8293a520fcac618 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 2 Feb 2014 16:42:29 -0500 Subject: [PATCH] - Added a workaround for when we call ``fcntl.ioctl()`` to get at ``TERMWIDTH``; if the function returns zero, as is reported to occur in some pseudo-ttys, the message wrapping system is disabled in the same way as if ``ioctl()`` failed. #172 --- alembic/util.py | 2 ++ docs/build/changelog.rst | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/alembic/util.py b/alembic/util.py index 49fea280..015f732e 100644 --- a/alembic/util.py +++ b/alembic/util.py @@ -40,6 +40,8 @@ try: ioctl = fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack('HHHH', 0, 0, 0, 0)) _h, TERMWIDTH, _hp, _wp = struct.unpack('HHHH', ioctl) + if TERMWIDTH <= 0: # can occur if running in emacs pseudo-tty + TERMWIDTH = None except (ImportError, IOError): TERMWIDTH = None diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index a3f7793e..e78bad55 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -5,6 +5,15 @@ Changelog .. changelog:: :version: 0.6.3 + .. change:: + :tags: bug + :tickets: 172 + + Added a workaround for when we call ``fcntl.ioctl()`` to get at + ``TERMWIDTH``; if the function returns zero, as is reported to occur + in some pseudo-ttys, the message wrapping system is disabled in the + same way as if ``ioctl()`` failed. + .. change:: :tags: feature :tickets: 171 -- 2.47.2