Opened 18 years ago

Closed 18 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 Holovaty
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: no UI/UX: no

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@…> 18 years ago.
resolve_numbers.patch (715 bytes ) - added by Chris Beaven 18 years ago.
With a regular expression

Download all attachments as: .zip

Change History (5)

by Collin Grady <cgrady@…>, 18 years ago

by Chris Beaven, 18 years ago

Attachment: resolve_numbers.patch added

With a regular expression

comment:1 by Chris Beaven, 18 years ago

Summary: [patch] Fix resolve_variable to return negative numbers as numbers[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 by Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

Fixed as part of [4690].

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