Skip to content

Conversation

cartland
Copy link

This library crashes when total_imaginary_width == 0.0 because the modulo cannot divide by zero. Although it's probably a bug if the a user of the library is trying to render something with width == 0, the library doesn't need to crash here.

We can use start = 0.0 as a reasonable value for a width of 0.

I came across this issue because I am using a collection of libraries that ultimately depend on this library. Since I'm not an owner of the libraries using this API, I thought it would be easiest to address this crash instead of changing the usage of libraries that depend on this one.

Please review the following checklist.

  • [?] Docstrings on all new or modified functions / classes: I don't know enough about the context for render_indeterminate() or RenderResult to provide a useful docstring. I am just trying to fix a crash.
  • [?] Updated documentation: I do not know enough about the documentation to determine if this needs additional documentation.
  • [?] Updated CHANGELOG.md (where appropriate): I do not know enough about the prevalence of this issue to know if it's worth a CHANGELOG.md update.

This library crashes when total_imaginary_width == 0.0 because the modulo cannot divide by zero. Although it's probably a bug if the a user of the library is trying to render something with width == 0, the library doesn't need to crash here.

We can use start = 0.0 as a reasonable value for a width of 0.
@willmcgugan
Copy link
Member

I'll need a regression test for this.

@cartland
Copy link
Author

Makes sense. I'm not sure I'll have time to create a regression test. I'm unblocked in my workflow and wanted to share in case it is helpful for others. Since my work is a few steps removed from this library, I am not very familiar with the conditions to trigger this issue or how to write tests. I also don't see others reporting the same issue in the issue tracker, so maybe it only happens under a rare condition. Feel free to close this if you decide not to maintain it, or we can leave it pending here in case I have some time in the coming weeks to figure out how to write some tests.

@TomJGooding
Copy link
Contributor

TomJGooding commented Aug 26, 2025

I have no idea what the library using Textual is doing, but here's a simple MRE if it helps:

from textual.app import App, ComposeResult
from textual.widgets import ProgressBar


class ProgressBarApp(App):
    CSS = """
    ProgressBar > Bar { width: 0; }
    """

    def compose(self) -> ComposeResult:
        yield ProgressBar()


if __name__ == "__main__":
    ProgressBarApp().run()

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.

3 participants