Opened 13 years ago
Closed 13 years ago
#16514 closed Bug (fixed)
Classic integer division used in django.template.defaultfilters
Reported by: | Owned by: | Kiran Busi | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
In defaultfilters.py line 93 we have
nan = (1e200 * 1e200) / (1e200 * 1e200)
When running python with -Qwarnall this triggers a warning:
defaultfilters.py:93: DeprecationWarning: classic float division
nan = (1e200 * 1e200) / (1e200 * 1e200)
Functionally, this is not really a problem -- the expression results in nan whether the '/' is interpreted as 'floored' or 'true' division. It just produces a bit of terminal noise for those of us who habitually keep the warnings on.
Attachments (3)
Change History (13)
by , 13 years ago
Attachment: | classic_division_fix.diff added |
---|
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 13 years ago
Has patch: | set |
---|
comment:3 by , 13 years ago
Owner: | changed from | to
---|
comment:4 by , 13 years ago
Owner: | changed from | to
---|
comment:5 by , 13 years ago
Needs tests: | set |
---|---|
Owner: | changed from | to
comment:6 by , 13 years ago
Needs tests: | unset |
---|
Not sure how to test for warnings, but I think important thing is to test for nan; Created the test
comment:7 by , 13 years ago
Wouldn't float('nan')
be better than the magical fomula? kman's test could be useful to ensure this works across all versions -- though it shouldn't be nested inside the test_floatformat
method.
comment:8 by , 13 years ago
Removed the test completely (b/c it's nested ) and it seems a bit superflous. Modified defaultFilters.py line 91 to be: nan = float('nan')
comment:9 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Ah; see the notes in defaultfilter.py regarding "Python Issue757815 and Issue1080440" -- let's just go with the classic_division_fix.diff for now until we get past python 2.5/2.6.
Use explicit floored division instead