#4276 closed (fixed)
django.contrib.webdesign's {% lorem N w %} fails where N >= 20
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Contrib apps | Version: | dev |
Severity: | Keywords: | webdesign lorem ipsum | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The code path handling inserting 20 or more lorem ipsum words (django/contrib/webdesign/lorem_ipsum.py: def words) ends up passing a negative number as the second argument to random.sample().
As well, the function would also fail if the requested word count was greater than len(WORDS). I have a patch that corrects this.
Attachments (1)
Change History (6)
by , 18 years ago
Attachment: | lorem_words.diff added |
---|
comment:1 by , 18 years ago
Note as well that the django/contrib/webdesign files should have the svn:eol-style=native property added to them:
cd django/contrib/webdesign
find . -name "*.py" | xargs svn ps svn:eol-style native
Cheers
comment:2 by , 18 years ago
follow-up: 5 comment:3 by , 18 years ago
Was the problem case you are referring to something like this:
{% lorem 32 w %}
I'm going to commit a slightly simpler patch that fixes this and close the ticket. If there's another example that fails, could you reopen and give the example. It's hard to write a test for this code, since the output is random, but I'd at least like to make sure we're fixing the right problem here.
comment:4 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 18 years ago
Replying to mtredinnick:
Was the problem case you are referring to something like this:
{% lorem 32 w %}
Doh! That was the case mentioned in the ticket title. I was concentrating on the summary too much. Nothing to see here. Move along. :-(
patch to fix the issues described