Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#4276 closed (fixed)

django.contrib.webdesign's {% lorem N w %} fails where N >= 20

Reported by: Trent Mick <trentm@…> 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)

lorem_words.diff (1002 bytes ) - added by Trent Mick <trentm@…> 18 years ago.
patch to fix the issues described

Download all attachments as: .zip

Change History (6)

by Trent Mick <trentm@…>, 18 years ago

Attachment: lorem_words.diff added

patch to fix the issues described

comment:1 by Trent Mick <trentm@…>, 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 Malcolm Tredinnick, 18 years ago

(In [5189]) Added native eol-style settings to necessary files. Refs #4276.

comment:3 by Malcolm Tredinnick, 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 Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

(In [5190]) Fixed #4276 -- Fixed a crash in the lorem tag when more than 20 words were
requested.

in reply to:  3 comment:5 by Malcolm Tredinnick, 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. :-(

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