Ticket #1647 (closed defect: fixed)
i18n: format_decimal does not work with num_places=0
| Reported by: | Felix.Schwarz | Owned by: | anonymous |
|---|---|---|---|
| Priority: | low | Milestone: | 1.0.x bugfix |
| Component: | TurboGears | Version: | 1.0.4b3 |
| Severity: | minor | Keywords: | |
| Cc: |
Description
I noticed that format_decimal implicitely asserts num_places > 0.
Using code like this
assert format_decimal(5.9, 0, "de")=="6"
generates the following exception:
====================================================================== ERROR: turbogears.i18n.tests.test_format.test_format_numbers ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/nose/case.py", line 202, in runTest self.test(*self.arg) File "/home/fs/3rdparty_svn/TurboGears/1.0/turbogears/i18n/tests/test_format.py", line 40, in test_format_numbers assert format_decimal(5.9, 0, "de")=="6" File "/home/fs/3rdparty_svn/TurboGears/1.0/turbogears/i18n/format.py", line 141, in format_decimal num, decimals = str.split(".") ValueError: need more than 1 value to unpack
I attached a patch which should work for 1.1 also - unfortunately I can't confirm this right now because I do not have all the necessary modules for 1.1 installed.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
