Skip to content

Commit b06a3a4

Browse files
committed
Merge branch '2.1' into 2.2
2 parents 506bf4e + c03ed22 commit b06a3a4

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ workflows:
6565
requires: ["Test"]
6666
matrix:
6767
parameters:
68-
version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
68+
version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
6969
- orb/docs:
7070
name: "Docs"
7171
requires: ["Test"]

invoke/terminals.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,18 @@ def _pty_size() -> Tuple[Optional[int], Optional[int]]:
8787
# Sentinel values to be replaced w/ defaults by caller
8888
size = (None, None)
8989
# We want two short unsigned integers (rows, cols)
90-
fmt = "HH"
90+
# Note: TIOCGWINSZ struct contains 4 unsigned shorts, 2 unused
91+
fmt = "HHHH"
9192
# Create an empty (zeroed) buffer for ioctl to map onto. Yay for C!
92-
buf = struct.pack(fmt, 0, 0)
93+
buf = struct.pack(fmt, 0, 0, 0, 0)
9394
# Call TIOCGWINSZ to get window size of stdout, returns our filled
9495
# buffer
9596
try:
9697
result = fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, buf)
9798
# Unpack buffer back into Python data types
9899
# NOTE: this unpack gives us rows x cols, but we return the
99100
# inverse.
100-
rows, cols = struct.unpack(fmt, result)
101+
rows, cols, *_ = struct.unpack(fmt, result)
101102
return (cols, rows)
102103
# Fallback to emptyish return value in various failure cases:
103104
# * sys.stdout being monkeypatched, such as in testing, and lacking

sites/www/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
Changelog
33
=========
44

5+
- :bug:`1038` (fixed in :issue:`1040`) Python 3.14 tweaked the behavior of
6+
`fcntl` to raise `SystemError` on buffer overflows, which our interpretation
7+
of `termios.TIOCGWINSZ` technically was (we care only about the first two
8+
fields in what is technically a four-field struct with half the fields
9+
unused). This has been fixed by unpacking all 4 fields and then discarding
10+
the unused fields during processing.
11+
12+
Thanks to ``@kasium`` for the original bug report and to ``@rathann`` and
13+
``@BradleyKirton`` for workshopping the patch into its final shape.
514
- :release:`2.2.0 <2023-07-12>`
615
- :feature:`-` Remove the somewhat inaccurate subclass requirement around
716
`~invoke.config.Config`'s ``.clone(into=...)`` constructor call. It was

0 commit comments

Comments
 (0)