Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#12071 closed (wontfix)

Numeric literals like "2." are incorrectly treated as Variables

Reported by: Johannes Dollinger Owned by: nobody
Component: Template system Version: 1.1
Severity: Keywords: pycamp2010
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

>>> Variable("2.").resolve(Context())
...
VariableDoesNotExist: Failed lookup for key [2] in u'[{}]'
>>> Variable("2.").resolve(Context({"2": {"": "foo"}}))
'foo'

That should either be treated as a literal float(2) or raise TemplateSyntaxError.

Change History (7)

comment:1 by anonymous, 14 years ago

Component: UncategorizedTemplate system

comment:2 by Russell Keith-Magee, 14 years ago

milestone: 1.2
Triage Stage: UnreviewedDesign decision needed

This needs some discussion - the docs are ambiguous on whether an integer can be used as the first (or only) character in a context variable.

comment:3 by jjconti, 14 years ago

This doen't look like a bug. BTW, docs are clear: "Variable names must consist of any letter (A-Z), any digit (0-9), an underscore or a dot."

comment:4 by jjconti, 14 years ago

This is behaviour is explicitly coded in Django source code: http://code.djangoproject.com/browser/django/trunk/django/template/__init__.py#L681

comment:5 by jjconti, 14 years ago

Keywords: pycamp2010 added

comment:6 by James Bennett, 14 years ago

Resolution: wontfix
Status: newclosed

This is, as the comment above points out, by design; yes, Python accepts it as a float, but the Django template language isn't Python and doesn't support the same range of things.

comment:7 by Jacob, 12 years ago

milestone: 1.2

Milestone 1.2 deleted

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