statistics: Fix geometric_mean() error message for negative inputs#149246
statistics: Fix geometric_mean() error message for negative inputs#149246rhettinger merged 2 commits intopython:mainfrom
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Test failures are unrelated. BTW, I think this small fix is fine for backports (issue valid for v3.13). |
The error message was constructed with two positional arguments to
StatisticsError, causing str(e) to display as a tuple:
"('No negative inputs allowed', -2.0)". Use an f-string instead so
the value is embedded directly in the message string.
4375281 to
7eed882
Compare
|
Thanks for the review! |
|
In order to keep the commit history intact, please avoid squashing or amending history and then force-pushing to the PR. Reviewers often want to look at individual commits. When the PR is merged, everything will be squashed into a single commit. |
|
Let's not backport this. Besides being a minor edit, it wasn't actually wrong. We sometimes to supply the value object as the last element of the tuple so that a user can extract it. In this particular case, I approved the edit because the result looks nice and because the tuple with value style is not used elsewhere in this module. |
geometric_mean()raisedStatisticsErrorwith two positional arguments,causing
str(e)to display as a tuple:Every other
StatisticsErrorin the module uses a single string message.Replaced with an f-string so the message reads: