From 7eed882737c9ce82b56124a8b7af7960c63c1423 Mon Sep 17 00:00:00 2001 From: htjworld <116538001+htjworld@users.noreply.github.com> Date: Sat, 2 May 2026 02:36:26 +0900 Subject: [PATCH] statistics: Fix geometric_mean() error message for negative inputs 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. --- Lib/statistics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/statistics.py b/Lib/statistics.py index 32fcf2313a815a..01ca6c51dafcaf 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -248,7 +248,7 @@ def count_positive(iterable): elif x == 0.0: found_zero = True else: - raise StatisticsError('No negative inputs allowed', x) + raise StatisticsError(f'No negative inputs allowed: {x!r}') total = fsum(map(log, count_positive(data)))