Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#10945 closed (wontfix)

Typo in get_XXX_display() crashes runserver

Reported by: Scot Hacker Owned by: nobody
Component: runserver Version: 1.0
Severity: Keywords: admin, runserver, get_display
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In 1.1 beta 1 SVN-10638, the following code, which is missing the parentheses in self.get_title_display() will crash runserver when an admin view is loaded. Mac OS raises a "Python has quit unxpectedly" dialog and a shell prompt is returned. This error should bubble up to where it can be reported in the console or browser.

class CommitteeJob(models.Model):
    title = models.CharField(choices=COMMITTEE_JOBS_CHOICES,max_length=12)
    reports_to = models.ForeignKey(BoardPosition)

    def __unicode__(self):
        return u'%s' % (self.get_title_display)

Change History (2)

comment:1 Changed 10 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed
Summary: Typo in get_display() crashes runserverTypo in get_XXX_display() crashes runserver

The unicode definition you provide implements an infinite loop, because get_title_display is a curried method that includes a call to unicode on the object into which it has been curried.

On my OS X install, this is correctly raised as a "maximum recursion depth exceeded" RuntimeError. If your Python install doesn't do this, then it is your Python install that is at fault.

For the sake of posterity, it would be helpful if you would provide details of your Python install so that others experiencing this problem can find and diagnose the problem. However, there isn't much we can do to fix this.

comment:2 Changed 10 years ago by Scot Hacker

The error reported occurs with the native Python 2.5.1 shipped in Mac OS X Leopard 10.5.6.

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