Bug 2457780 - traceback, redirect output: fontquery-diff --loose-comparison 44 > a
Summary: traceback, redirect output: fontquery-diff --loose-comparison 44 > a
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-fontquery
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Akira TAGOH
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2026-04-13 08:05 UTC by Petr Sklenar
Modified: 2026-04-14 08:38 UTC (History)
1 user (show)

Fixed In Version: python-fontquery-1.33-1.fc45
Clone Of:
Environment:
Last Closed: 2026-04-14 08:38:56 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Petr Sklenar 2026-04-13 08:05:08 UTC
There is traceback when redirecting output to file.
(in my case to fpaste: fontquery-diff --loose-comparison 44 | fpaste)

Reproducible: Always

Steps to Reproduce:
1.fontquery-diff --loose-comparison 44 > /tmp/a

❯ rpm -qf /usr/bin/fontquery-diff /usr/bin/python3
fontquery-1.32-1.fc44.noarch
python3-3.14.3-2.fc44.x86_64
Actual Results:
/usr/bin/python3 -sP /usr/bin/fontquery-diff --loose-comparison 44 > /tmp/a
* Comparison between 44 and local
* This may take some time...(89/89)
Traceback (most recent call last):
  File "/usr/bin/fontquery-diff", line 7, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/lib/python3.14/site-packages/fontquery/diff.py", line 207, in main
    for s in next(g):
             ~~~~^^^
  File "/usr/lib/python3.14/site-packages/fontquery/htmlformatter.py", line 635, in generate_diff
    yield from renderer.render_diff(langdata, missing_a,
                                    missing_b, langdiffdata)
  File "/usr/lib/python3.14/site-packages/fontquery/htmlformatter.py", line 437, in __diff__
    for s in TextRenderer.format_line([ColoredText('Language',
             ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
                                                   attrs=['bold']),
                                                   ^^^^^^^^^^^^^^^^
    ...<7 lines>...
                                                   attrs=['bold'])
                                                   ^^^^^^^^^^^^^^^
                                       ]):
                                       ^^
  File "/usr/lib/python3.14/site-packages/fontquery/htmlformatter.py", line 417, in format_line
    colsize = int(os.get_terminal_size().columns / len(column))
                  ~~~~~~~~~~~~~~~~~~~~^^
OSError: [Errno 25] Inappropriate ioctl for device


Expected Results:
no traceback, output is created

------------
'os' doesnt set any terminal size when no TTY set:
❯ python3 -c "import os; print(os.get_terminal_size())" > a
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import os; print(os.get_terminal_size())
                     ~~~~~~~~~~~~~~~~~~~~^^
OSError: [Errno 25] Inappropriate ioctl for device

Comment 1 Petr Sklenar 2026-04-13 08:19:34 UTC
❯ echo "C: $COLUMNS, L: $LINES"
C: 153, L: 37
❯ python3 -c "import shutil; print(shutil.get_terminal_size())"
os.terminal_size(columns=153, lines=37)

---------- posible patch to change os > shutil


❯ diff -u /usr/lib/python3.14/site-packages/fontquery/htmlformatter.py /usr/lib/python3.14/site-packages/fontquery/htmlformatter-NEW.py
--- /usr/lib/python3.14/site-packages/fontquery/htmlformatter.py	2026-01-30 01:00:00.000000000 +0100
+++ /usr/lib/python3.14/site-packages/fontquery/htmlformatter-NEW.py	2026-04-13 10:15:41.802958382 +0200
@@ -30,6 +30,7 @@
 import os
 import re
 import sys
+import shutil
 from typing import Any, Dict, Iterator
 NO_MARKDOWN = False
 try:
@@ -414,7 +415,7 @@
     def format_line(cls, column: list[ColoredText]) -> Iterator[str]:
         ll = []
         retval = ''
-        colsize = int(os.get_terminal_size().columns / len(column))
+        colsize = int(shutil.get_terminal_size().columns / len(column))
         colsize = 15 if colsize <= 15 else colsize
         for i, s in enumerate(column):
             n = len(s)

Comment 2 Petr Sklenar 2026-04-13 08:43:17 UTC
filled https://github.com/fedora-i18n/fontquery/issues/13

Comment 3 Fedora Update System 2026-04-14 02:23:43 UTC
FEDORA-2026-023704e32f (python-fontquery-1.33-1.fc45) has been submitted as an update to Fedora 45.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-023704e32f

Comment 4 Fedora Update System 2026-04-14 08:38:56 UTC
FEDORA-2026-023704e32f (python-fontquery-1.33-1.fc45) has been pushed to the Fedora 45 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.