Skip to content

fix: catch OverflowError in num() alongside ValueError#256

Open
koteshyelamati wants to merge 1 commit into
jaraco:mainfrom
koteshyelamati:patch-1
Open

fix: catch OverflowError in num() alongside ValueError#256
koteshyelamati wants to merge 1 commit into
jaraco:mainfrom
koteshyelamati:patch-1

Conversation

@koteshyelamati

Copy link
Copy Markdown

Problem

num() only catches ValueError when calling int(count), but int(float('inf')) raises OverflowError — which is not a subclass of ValueError — so the intended BadNumValueError is never raised:

import inflect
p = inflect.engine()
p.num(float('inf'))
# OverflowError: cannot convert float infinity to integer
# Expected: BadNumValueError

Fix

Add OverflowError to the except tuple so all numeric conversion failures produce the documented BadNumValueError.

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