diff options
| author | Tim Graham <timograham@gmail.com> | 2018-07-02 16:10:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-02 16:10:35 -0400 |
| commit | 4009e1f2abe6268ba116dd09fbbecfc35b84f89a (patch) | |
| tree | ec175298a8cb78ddcf393a79f36d7224b16b4099 | |
| parent | 0e64e046a481c345358b1040df7c89480ad198e8 (diff) | |
Removed unused code in django.db.backends.utils.format_number().
| -rw-r--r-- | django/db/backends/utils.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/django/db/backends/utils.py b/django/db/backends/utils.py index e7b9c30193..2c404b3a0b 100644 --- a/django/db/backends/utils.py +++ b/django/db/backends/utils.py @@ -225,18 +225,14 @@ def format_number(value, max_digits, decimal_places): """ if value is None: return None - if isinstance(value, decimal.Decimal): - context = decimal.getcontext().copy() - if max_digits is not None: - context.prec = max_digits - if decimal_places is not None: - value = value.quantize(decimal.Decimal(1).scaleb(-decimal_places), context=context) - else: - context.traps[decimal.Rounded] = 1 - value = context.create_decimal(value) - return "{:f}".format(value) + context = decimal.getcontext().copy() + if max_digits is not None: + context.prec = max_digits if decimal_places is not None: - return "%.*f" % (decimal_places, value) + value = value.quantize(decimal.Decimal(1).scaleb(-decimal_places), context=context) + else: + context.traps[decimal.Rounded] = 1 + value = context.create_decimal(value) return "{:f}".format(value) |
