Skip to content
Myr

Windows compatibility

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Importing fcntl and termios outside a try block in Windows would cause an error. These modules are only used inside ioctl_gwinsz, so we can import them there.

authored by Henrique Pereira · committed by Henrique Pereira · parent 5b7b729 · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:click.py+2 added-2 removed
18 unmodified lines
19import inspect20import getpass21import optparse22import textwrap23import fcntl24import termios23import struct24from itertools import chain2526
45 unmodified lines
72 ``(width, height)`` in columns and rows.73 """74 def ioctl_gwinsz(fd):75 try:76 import fcntl77 import termios78 cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))79 except Exception:80 return81 return cr
1452 unmodified lines