Skip to content

_pty_size does not handle SystemError (python 3.14) #1038

@kasium

Description

@kasium

With python3.14 result = fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, buf) can also raise a SystemError which is not handelnd. Please add it to the except clause

invoke/invoke/terminals.py

Lines 95 to 112 in 2a8f95f

try:
result = fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, buf)
# Unpack buffer back into Python data types
# NOTE: this unpack gives us rows x cols, but we return the
# inverse.
rows, cols = struct.unpack(fmt, result)
return (cols, rows)
# Fallback to emptyish return value in various failure cases:
# * sys.stdout being monkeypatched, such as in testing, and lacking
# * .fileno
# * sys.stdout having a .fileno but not actually being attached to a
# * TTY
# * termios not having a TIOCGWINSZ attribute (happens sometimes...)
# * other situations where ioctl doesn't explode but the result isn't
# something unpack can deal with
except (struct.error, TypeError, IOError, AttributeError):
pass
return size

Python changelog: https://docs.python.org/3.14/whatsnew/changelog.html#id13

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions