Opened 7 years ago

Closed 7 years ago

Last modified 5 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: UI/UX:

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 Changed 7 years ago by anonymous

Component: UncategorizedTemplate system
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 7 years ago by Russell Keith-Magee

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 Changed 7 years ago by jjconti

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 Changed 7 years ago by jjconti

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

comment:5 Changed 7 years ago by jjconti

Keywords: pycamp2010 added

comment:6 Changed 7 years ago by James Bennett

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 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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