#24569: Template `date` filter fails with TypeError
---------------------------------+------------------------------------
     Reporter:  thenikso         |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Template system  |                  Version:  1.8
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by claudep):

 Surely, the fact that `get_language` might return `None` is new in 1.8,
 and it appears that some functions (like `check_for_language` in this
 issue) are not prepared to receive a `None` language. Still, I think that
 returning `None` when no language is activated is the right thing. I only
 hope we'll not have to patch too much Django internals for that...

 To fix this one, the following patch might be sufficient:
 {{{
 #!diff
 diff --git a/django/utils/translation/trans_real.py
 b/django/utils/translation/trans_real.py
 index ff84589..bebe69f 100644
 --- a/django/utils/translation/trans_real.py
 +++ b/django/utils/translation/trans_real.py
 @@ -406,7 +406,7 @@ def check_for_language(lang_code):
      <https://www.djangoproject.com/weblog/2007/oct/26/security-fix/>.
      """
      # First, a quick check to make sure lang_code is well-formed (#21458)
 -    if not language_code_re.search(lang_code):
 +    if lang_code is None or not language_code_re.search(lang_code):
          return False
      for path in all_locale_paths():
          if gettext_module.find('django', path, [to_locale(lang_code)]) is
 not None:
 }}}
 Test needed, of course.

--
Ticket URL: <https://code.djangoproject.com/ticket/24569#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.e523fb21180b1b6057819813808ee617%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to