Django

Code

Ticket #4276 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: Trent Mick <trentm@gmail.com> Assigned to: adrian
Milestone: Component: Contrib apps
Version: SVN Keywords: webdesign lorem ipsum
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

lorem_words.diff (1.0 kB) - added by Trent Mick <trentm@gmail.com> on 05/11/07 02:47:40.
patch to fix the issues described

Change History

05/11/07 02:47:40 changed by Trent Mick <trentm@gmail.com>

  • attachment lorem_words.diff added.

patch to fix the issues described

05/11/07 02:49:24 changed by Trent Mick <trentm@gmail.com>

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

05/11/07 04:13:38 changed by mtredinnick

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

(follow-up: ↓ 5 ) 05/11/07 04:43:13 changed by mtredinnick

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.

05/11/07 04:44:13 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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

(in reply to: ↑ 3 ) 05/11/07 04:47:47 changed by mtredinnick

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. :-(


Add/Change #4276 (django.contrib.webdesign's {% lorem N w %} fails where N >= 20)




Change Properties
Action