Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1647 (closed defect: fixed)

Opened 12 years ago

Last modified 9 years ago

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:


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
  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.


format_decimal.patch Download (987 bytes) - added by Felix.Schwarz 12 years ago.

Change History

Changed 12 years ago by Felix.Schwarz

comment:1 Changed 11 years ago by chrisz

  • Status changed from new to closed
  • Resolution set to fixed

Applied in r4736.

comment:2 Changed 9 years ago by chrisz

  • Milestone changed from __unclassified__ to 1.0.x bugfix
Note: See TracTickets for help on using tickets.