Opened 4 years ago

Closed 4 years ago

#16938 closed Bug (fixed)

django.utils.formats.get_format skips values interpreted as false

Reported by: pikerr Owned by: nobody
Component: Internationalization Version: 1.3
Severity: Normal Keywords: utils get_format
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Here

    return _format_cache[cache_key] or getattr(settings, format_type)

it tries to evaluate getattr if _format_cache[cache_key] interprets as false.
Thereby if user sets some value in <LOCALE>/formats.py to the value interpreted by Python as False, then Django skips returning it.

For example,

if I set <SOME_LOCALE>/formats.py's THOUSAND_SEPARATOR to '' Django takes value from django.conf.settings instead of formats.py.

Attachments (2)

fix_format_false_interpretation.patch (991 bytes) - added by pikerr 4 years ago.
small patch
16938.empty-string-locale-format.diff (2.6 KB) - added by julien 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by pikerr

small patch

comment:1 Changed 4 years ago by ramiro

  • Component changed from Uncategorized to Internationalization
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 4 years ago by julien

comment:2 Changed 4 years ago by julien

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

Fixed in r17017.

Note: See TracTickets for help on using tickets.
Back to Top