Skip to content

fix terminal width#694

Open
tmzullinger wants to merge 1 commit intonicfit:0.9.xfrom
tmzullinger:fix-terminal-width
Open

fix terminal width#694
tmzullinger wants to merge 1 commit intonicfit:0.9.xfrom
tmzullinger:fix-terminal-width

Conversation

@tmzullinger
Copy link
Copy Markdown
Contributor

0f81cd1 (Remove eyed3.utils.console.getTtySize() implementation (#682), 2025-10-22) didn't take into account the difference in the order of the tuple contents. As a result, it now returns the terminal height when it intends to return the width.

To demonstrate:

$ python -c 'print();
import shutil; from eyed3.utils.console import getTtySize;
print(shutil.get_terminal_size());
print(tuple(shutil.get_terminal_size()));
print(getTtySize())
'

os.terminal_size(columns=80, lines=24)
(80, 24)
(24, 80)

Fortunately, the output from shutil.get_terminal_size() is a named tuple. Use the os.terminal_size field names rather than slicing to get the terminal width in several locations. This makes the code clearer and less likely to accidentally transpose the height and width.

Fixes #689

0f81cd1 (Remove eyed3.utils.console.getTtySize() implementation (nicfit#682),
2025-10-22) didn't take into account the difference in the order of the
tuple contents.  As a result, it now returns the terminal height when it
intends to return the width.

To demonstrate:

    $ python -c 'print();
    import shutil; from eyed3.utils.console import getTtySize;
    print(shutil.get_terminal_size());
    print(tuple(shutil.get_terminal_size()));
    print(getTtySize())
    '

    os.terminal_size(columns=80, lines=24)
    (80, 24)
    (24, 80)

Fortunately, the output from shutil.get_terminal_size() is a named
tuple.  Use the `os.terminal_size` field names rather than slicing to
get the terminal width in several locations.  This makes the code
clearer and less likely to accidentally transpose the height and width.

Fixes nicfit#689
@tmzullinger
Copy link
Copy Markdown
Contributor Author

Before:

[test@a8a5c197f1f2 eyeD3]$ echo ${COLUMNS}x${LINES}
80x24

[test@a8a5c197f1f2 eyeD3]$ python eyed3/main.py tests/eyeD3-test-data/test.mp3
.../home/test/eyeD3/tests/eyeD3-test-data/test.mp3 [ 166.52 KB ]
------------------------
Time: 00:11 MPEG1, Layer III    [ 128 kb/s @ 44100 Hz - Joint stereo ]
------------------------
No ID3 v1.x/v2.x tag found!

After:

[test@a8a5c197f1f2 eyeD3]$ python eyed3/main.py tests/eyeD3-test-data/test.mp3
/home/test/eyeD3/tests/eyeD3-test-data/test.mp3                    [ 166.52 KB ]
--------------------------------------------------------------------------------
Time: 00:11 MPEG1, Layer III    [ 128 kb/s @ 44100 Hz - Joint stereo ]
--------------------------------------------------------------------------------
No ID3 v1.x/v2.x tag found!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Files' paths are truncated in the CLI output

1 participant