﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17414	intcomma raises ZeroDivisionError for locales whose NUMBER_GROUPING is unspecified	jittat	nobody	"When using locales that do not specify `NUMBER_GROUPING` (like 'fa','ja','th',) template filter `intcomma` (from humanize) raises ZeroDivisionError.

'''Version:''' Django 1.4 pre-alpha SVN-17202

'''How to reproduce:'''

1. Make sure that `USE_L10N = True` in `settings.py`
2. Try this code in shell

{{{
from django.utils import translation
translation.activate('th')
t = ""{% load humanize %}}{{ 100|intcomma }}""
from django.template import Template, Context
Template(t).render(Context())
}}}

3. You can change 'th' to 'ja', 'mn', 'ro' and many others.

'''Possible cause:'''

This is not the issue directly related to contrib.humanize's `intcomma`.

The exception occurs in function `format` in `django.utils.numberformat` when Django tries to divide something with parameter `grouping`.  This parameter is assigned in function `number_format` in `django.utils.formats` from a call to `get_format('NUMBER_GROUPING')`, which returns `0` for many locales (e.g., th, ja, km, zh) with no definition of `NUMBER_GROUPING` in the format files.  Therefore, you get `ZeroDivisionError`.

'''How to fix:'''

I am not sure where to put the fixing code.  These are the options:

* Use something like 3 as a default for `NUMBER_GROUPING`.
* Change function `format` in `django.utils.numberformat` to make sure that `grouping `is non-zero (and if it is zero, use something like 3 as a default).

Since I am not sure where to put the fix, I have not tried to produce the patch.  I can try to do that for the 2nd option if it makes sense."	Bug	closed	Internationalization	dev	Normal	fixed	ZeroDivisionError, intcomma		Accepted	0	0	1	0	0	0
