Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] Printing table into console results in infinite loop #1682

Closed
jan920 opened this issue Nov 12, 2021 · 1 comment · Fixed by #1683
Closed

[BUG] Printing table into console results in infinite loop #1682

jan920 opened this issue Nov 12, 2021 · 1 comment · Fixed by #1683
Labels
bug Something isn't working

Comments

@jan920
Copy link

jan920 commented Nov 12, 2021

Following code ends up with rich being in infinite loop and never finishing:

Platform used: IOS

Code to reproduce the issue:

from rich.console import Console
from rich.table import Table

if __name__ == '__main__':
    with open('output.txt', 'w') as file_output:
        console = Console(file=file_output)

        table = Table(title='Model Comparison', show_lines=True)
        table.add_column('Text', justify='left')
        table.add_column('All match', justify='left')
        table.add_column('True Label', justify='center')
        for model_name in ['model_name']:
            table.add_column(f'{model_name}', justify='center')
        table.add_row(
            'เป็นเกมที่ต้องมีความอดทนมากที่สุดตั้งเเต่เคยเล่นมา',
            'differences',
        )
        print('printing to console')
        console.print(table)

Platform
What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

Diagnose
I may ask you to cut and paste the output of the following commands. It may save some time if you do it now.

python -m rich.diagnose
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=172 ColorSystem.EIGHT_BIT>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = '256'                                                         │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'> │
│           height = 16                                                            │
│    is_alt_screen = False                                                         │
│ is_dumb_terminal = False                                                         │
│   is_interactive = True                                                          │
│       is_jupyter = False                                                         │
│      is_terminal = True                                                          │
│   legacy_windows = False                                                         │
│         no_color = False                                                         │
│          options = ConsoleOptions(                                               │
│                        size=ConsoleDimensions(width=172, height=16),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=172,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=16,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=172, height=16)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 172                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
python -m rich._windows

platform="Darwin"
WindowsConsoleFeatures(vt=False, truecolor=False)

pip freeze | grep rich
rich==10.13.0

@willmcgugan willmcgugan added bug Something isn't working and removed Needs triage labels Nov 13, 2021
@github-actions
Copy link

Did I solve your problem?

Consider sponsoring the ongoing work on Rich and Textual.

Or buy me a coffee to say thanks.

Will McGugan

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Nov 23, 2021
10.14.0

Fixed

Fixed progress speed not updating when total doesn't change
Fixed superfluous new line in Status Textualize/rich#1662
Fixed Windows legacy width again
Fixed infinite loop in set_cell_size Textualize/rich#1682

Added

Added file protocol to URL highlighter Textualize/rich#1681
Added rich.protocol.rich_cast

Changed

Allowed __rich__ to work recursively
Allowed Text classes to work with sep in print Textualize/rich#1689
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants