--
Ticket URL: <https://code.djangoproject.com/ticket/18400>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Hmm, I have an odd issue with the testsuite here:
{{{
PYTHONPATH=.. ./runtests.py --settings=test_sqlite --verbosity 2
--failfast templates.Templates
}}}
returns without failures for the patch in question, running the full
testsuite results in errors in the testcase in question :(
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:1>
* stage: Unreviewed => Design decision needed
Comment:
It would be interesting to investigate why the `ignore_failures` argument
was added and what it does. Apparently it triggers two different
resolution modes. Isn't that inconsistency a bad idea in itself? If so,
shouldn't we get rid of this argument?
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:2>
* stage: Design decision needed => Accepted
Comment:
I don't know what the right solution is, but it's definitely a bug.
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:3>
Comment (by luyikei):
I think that when TypeError happen, length should return 0.
I made pull request at https://github.com/django/django/pull/1633.
In shell if use my patch.
>>> from django import template
>>> t = template.Template("{{ asd|length }}{% if asd|length > 1 %}Hi from
an non existant variable!{% endif %}")
>>> c = template.Context({})
>>> print t.render(c)
0
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:4>
* cc: luyikei (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:5>
Comment (by apollo13):
@luyikei the question is how and if that's better than my patch… How many
errors do you get in the testsuite with that change? Also any thoughts to
the comments from Aymeric?
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:6>
Comment (by luyikei):
I think it is natural that {{ asd|length }} returns 0.
because actually {{ asd|length }} returns 0.But in {% if asd|length > 1 %}
, asd|length returns "".
So it should return 0 I think.
And my patch returns no failures.
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:7>
Comment (by susan):
@luyikei I tested your PR against the test suites in tests/templates and
tests/test_templates and the test_template tests fail. Specifically,
template_tests/test.py in L620. I'll poke at the existing tests more later
today to see how I start changing them.
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:8>
* cc: susan.tan.fleckerl@… (added)
* owner: nobody => susan
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:9>
Comment (by anonymous):
Thanks you susan
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:10>
* needs_docs: 0 => 1
Comment:
Since this is a backwards-incompatible change, it should be documented.
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:11>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"484f3edf1e79388f73dcb07e39d79d0c5029ae9e"]:
{{{
#!CommitTicketReference repository=""
revision="484f3edf1e79388f73dcb07e39d79d0c5029ae9e"
Fixed #18400 -- Modified length template filter to return 0 for unknown
variables.
Thanks Florian for the bug report, luyikei for the initial code patch, and
Bouke for the code review feedback.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18400#comment:12>