Skip to content

Fix naturalsize() with custom formats containing text - #457

Open
amlaban65 wants to merge 1 commit into
python-humanize:mainfrom
amlaban65:fix-naturalsize-format-text
Open

amlaban65 wants to merge 1 commit into
python-humanize:mainfrom
amlaban65:fix-naturalsize-format-text

Conversation

@amlaban65

Copy link
Copy Markdown

Fixes #366

Changes proposed in this pull request:

  • The rollover check from Fix naturalsize() rounding rollover at unit boundaries #329 calls float() on the formatted string, so a format like "Size: %.1f" raised ValueError. Skip the rollover check when the formatted value isn't a plain number, which restores the 4.15 output for these formats.
  • Add tests for a format with text before and after the number.

The rounding rollover added in python-humanize#329 calls float() on the formatted
string, which raises ValueError when the format has text around the
number. Skip the rollover check in that case.

Fixes python-humanize#366
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.

naturalsize() raises ValueError for custom format strings with text

1 participant