Opened 9 years ago

Closed 9 years ago

Last modified 7 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


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

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

Change History (7)

comment:1 Changed 9 years ago by anonymous

Component: UncategorizedTemplate system

comment:2 Changed 9 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 9 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 9 years ago by jjconti

This is behaviour is explicitly coded in Django source code:

comment:5 Changed 9 years ago by jjconti

Keywords: pycamp2010 added

comment:6 Changed 9 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 7 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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