Skip to content

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

@jan920

Description

@jan920

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions