Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#12071 closed (wontfix)

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

Reported by: emulbreh 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:


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

  • Component changed from Uncategorized to Template system
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by russellm

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Design 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 6 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 6 years ago by jjconti

This is behaviour is explicitly coded in Django source code:

comment:5 Changed 6 years ago by jjconti

  • Keywords pycamp2010 added

comment:6 Changed 6 years ago by ubernostrum

  • Resolution set to wontfix
  • Status changed from new to closed

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 deleted

Milestone 1.2 deleted

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