{{{
$ python -Wall tests/runtests.py
humanize_tests.tests.HumanizeTests.test_i18n_intword
Testing against Django installed in '/home/tim/code/django/django' with up
to 3 processes
Creating test database for alias 'default'...
Creating test database for alias 'other'...
/home/tim/code/django/django/utils/translation/trans_real.py:373:
DeprecationWarning: Plural value must be an integer, got float
return getattr(t, translation_function)(singular, plural, number)
.
}}}
{{{
python -Wall tests/runtests.py
template_tests.filter_tests.test_filesizeformat.FunctionTests.test_localized_formats
Testing against Django installed in '/home/tim/code/django/django' with up
to 3 processes
Creating test database for alias 'default'...
Creating test database for alias 'other'...
/home/tim/code/django/django/utils/translation/trans_real.py:373:
DeprecationWarning: Plural value must be an integer, got float
return getattr(t, translation_function)(singular, plural, number)
.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27486>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Claude Paroz):
The exact rule about pluralizing floats/decimals depends on the language,
so whether we floor or ceil the number before passing it to `ngettext`
we'll do the right thing for some languages and wrong for others. This is
a known limitation of the `gettext` spec (in C, `ngettext` is only
accepting integers). We should make a choice and then document the
limitation.
It would not be impossible to try providing a language-specific hook in
the LANG_INFO structure and call that hook when converting floats to ints.
--
Ticket URL: <https://code.djangoproject.com/ticket/27486#comment:1>
Comment (by Tim Graham):
My [https://github.com/django/django/pull/7561 PR] does naive `int()`
casting. I closed it since it seems a more involved solution would be
better. Perhaps we could look to see how other projects handle the issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/27486#comment:2>
* status: assigned => new
* owner: Tim Graham => (none)
--
Ticket URL: <https://code.djangoproject.com/ticket/27486#comment:3>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/11459 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27486#comment:4>
* status: new => closed
* owner: (none) => Mariusz Felisiak <felisiak.mariusz@…>
* resolution: => fixed
Comment:
In [changeset:"9e38ed0536c7dc598a6c2c1bb774d0a8db3cdddc" 9e38ed05]:
{{{
#!CommitTicketReference repository=""
revision="9e38ed0536c7dc598a6c2c1bb774d0a8db3cdddc"
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().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27486#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"53ea535f13e988b13499a62bab3831eb44e19e06" 53ea535f]:
{{{
#!CommitTicketReference repository=""
revision="53ea535f13e988b13499a62bab3831eb44e19e06"
Refs #27486 -- Added tests for filesizeformat filter.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27486#comment:5>