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: | 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)
Change History (5)
by , 18 years ago
Attachment: | resolve_variable-negatives.patch added |
---|
by , 18 years ago
Attachment: | resolve_numbers.patch added |
---|
comment:1 by , 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 , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
With a regular expression