Opened 9 years ago

Closed 8 years ago

#3022 closed defect (fixed)

[patch] Fix resolve_variable to return negative numbers and floats as numbers

Reported by: Collin Grady <cgrady@…> Owned by: adrian
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

At present, if you do resolve_variable('-1', c), it will error trying to find "-1" as a valid key in the context, as compared to resolve_variable('1', c) returning 1

I'll admit that I don't know a lot about python, so there may be some more elegant way of accomplishing this check, but I have a tiny patch that does correct the issue.

Attachments (2)

resolve_variable-negatives.patch (518 bytes) - added by Collin Grady <cgrady@…> 9 years ago.
resolve_numbers.patch (715 bytes) - added by SmileyChris 9 years ago.
With a regular expression

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by Collin Grady <cgrady@…>

Changed 9 years ago by SmileyChris

With a regular expression

comment:1 Changed 9 years ago by SmileyChris

  • Summary changed from [patch] Fix resolve_variable to return negative numbers as numbers to [patch] Fix resolve_variable to return negative numbers and floats as numbers

Not only were negative numbers failing, floats weren't working either! (since '2.5'.isdigit() == False)
So there was some redundant code that was never going to work.

comment:2 Changed 9 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 8 years ago by mtredinnick

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

Fixed as part of [4690].

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