Opened 5 years ago

Closed 5 years ago

#23489 closed Bug (fixed)

Test failures with numpy 1.9

Reported by: Tim Graham Owned by: nobody
Component: Template system Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Installing numpy 1.9 and ./runtests template_tests will give some test failures like this:

Template test (Cached='True', TEMPLATE_STRING_IF_INVALID='', TEMPLATE_DEBUG=True): numpy-array-index02 -- FAILED. Got <type 'exceptions.IndexError'>, exception: index 5 is out of bounds for axis 0 with size 2
Traceback (most recent call last):

  File "/home/tim/code/django/tests/template_tests/tests.py", line 596, in test_templates
    output = self.render(test_template, vals)

  File "/home/tim/code/django/tests/template_tests/tests.py", line 622, in render
    output = test_template.render(context)

  File "/home/tim/code/django/django/template/base.py", line 150, in render
    return self._render(context)

  File "/home/tim/code/django/django/test/utils.py", line 89, in instrumented_test_render
    return self.nodelist.render(context)

  File "/home/tim/code/django/django/template/base.py", line 853, in render
    bit = self.render_node(node, context)

  File "/home/tim/code/django/django/template/debug.py", line 80, in render_node
    return node.render(context)

  File "/home/tim/code/django/django/template/debug.py", line 90, in render
    output = self.filter_expression.resolve(context)

  File "/home/tim/code/django/django/template/base.py", line 598, in resolve
    obj = self.var.resolve(context)

  File "/home/tim/code/django/django/template/base.py", line 739, in resolve
    value = self._resolve_lookup(context)

  File "/home/tim/code/django/django/template/base.py", line 769, in _resolve_lookup
    current = current[bit]

IndexError: index 5 is out of bounds for axis 0 with size 2

Attachments (1)

23489.diff (710 bytes) - added by Tim Graham 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by Tim Graham

Has patch: set

Here is the change in behavior:

NumPy < 1.9

>>> numpy.array(["first item", "second item"])['2']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: field named 2 not found

NumPy 1.9+

>>> numpy.array(["first item", "second item"])['2']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: index 2 is out of bounds for axis 0 with size 2

Attaching a patch to fix it. I guess we shouldn't backport, but require specific version of test dependencies in Jenkins as suggested in #21793.

The original issue where these tests were added: [7d5e35cd].

Changed 5 years ago by Tim Graham

Attachment: 23489.diff added

comment:2 Changed 5 years ago by Tim Graham <timograham@…>

In 4743a944295faccb494e31b7a805499bad2cedaa:

[1.7.x] Required numpy < 1.9 for tests; refs #23489.

comment:3 Changed 5 years ago by Tim Graham <timograham@…>

In 011541d948dac99100940e974f5cf243199be534:

[1.6.x] Required numpy < 1.9 for tests; refs #23489.

Backport of 4743a94429 from stable/1.7.x

comment:4 Changed 5 years ago by Tim Graham <timograham@…>

In df657a768248c07fdbdc950b08366f655d0f2f5d:

[1.4.x] Required numpy < 1.9 for tests; refs #23489.

Backport of 4743a94429 from stable/1.7.x

comment:5 Changed 5 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 12809e160995eb617fe394c75e5b9f3211c056ff:

Fixed #23489 -- Added numpy 1.9+ support in template lookups

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