From 9e38ed0536c7dc598a6c2c1bb774d0a8db3cdddc Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 9 Jun 2019 12:48:20 -0700 Subject: Fixed #27486 -- Fixed Python 3.7 DeprecationWarning in intword and filesizeformat filters. intword and filesizeformat passed floats to ngettext() which is deprecated in Python 3.7. The rationale for this warning is documented in BPO-28692: https://bugs.python.org/issue28692. For filesizeformat, the filesize value is expected to be an int -- it fills %d string formatting placeholders. It was likely coerced to a float to ensure floating point division on Python 2. Python 3 always does floating point division, so coerce to an int instead of a float to fix the warning. For intword, the number may contain a decimal component. In English, a decimal component makes the noun plural. A helper function, round_away_from_one(), was added to convert the float to an integer that is appropriate for ngettext(). --- docs/ref/contrib/humanize.txt | 9 ++++++++- docs/releases/3.0.txt | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/ref/contrib/humanize.txt b/docs/ref/contrib/humanize.txt index 9a30ce1aa4..edbdb136b0 100644 --- a/docs/ref/contrib/humanize.txt +++ b/docs/ref/contrib/humanize.txt @@ -57,7 +57,9 @@ e.g. with the ``'de'`` language: =========== Converts a large integer (or a string representation of an integer) to a -friendly text representation. Works best for numbers over 1 million. +friendly text representation. Translates ``1.0`` as a singular phrase and all +other numeric values as plural, this may be incorrect for some languages. Works +best for numbers over 1 million. Examples: @@ -74,6 +76,11 @@ e.g. with the ``'de'`` language: * ``1200000`` becomes ``'1,2 Millionen'``. * ``1200000000`` becomes ``'1,2 Milliarden'``. +.. versionchanged:: 3.0 + + All numeric values are now translated as plural, except ``1.0`` which is + translated as a singular phrase. This may be incorrect for some languages. + .. templatefilter:: naturalday ``naturalday`` diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt index f6a45ebfc9..e58a18f9da 100644 --- a/docs/releases/3.0.txt +++ b/docs/releases/3.0.txt @@ -416,6 +416,9 @@ Miscellaneous when ``doseq=False``, rather than iterating them, bringing it into line with the standard library :func:`urllib.parse.urlencode` function. +* ``intword`` template filter now translates ``1.0`` as a singular phrase and + all other numeric values as plural. This may be incorrect for some languages. + .. _deprecated-features-3.0: Features deprecated in 3.0 -- cgit v1.3