Skip to content

Reject bool/float/nan in maxcolwidths - #456

Open
Pitchfork-and-Torch wants to merge 1 commit into
astanin:masterfrom
Pitchfork-and-Torch:cook/maxcolwidths-reject-bool-nan
Open

Pitchfork-and-Torch wants to merge 1 commit into
astanin:masterfrom
Pitchfork-and-Torch:cook/maxcolwidths-reject-bool-nan

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Summary

maxcolwidths=True previously wrapped every character because bool is an int subclass. maxcolwidths=[float('nan')] bypassed the width <= 0 guard (NaN comparisons are false) and hung forever inside textwrap.

Require positive int widths (or None for unbound). Reject bool, floats, and non-finite values with a clear TypeError / ValueError.

Test plan

  • pytest test/test_regression.py::test_maxcolwidths_rejects_bool_float_nan
  • Normal maxcolwidths=5 still wraps as before

bool is an int subclass, so maxcolwidths=True previously wrapped every
character. float('nan') bypassed the width<=0 guard (NaN comparisons are
false) and hung forever inside textwrap. Require positive ints or None.
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.

1 participant