Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#4613 closed (invalid)

KeyError in sessions after changeset 5482 with newforms

Reported by: boobsd@… Owned by: adrian
Component: Forms Version: master
Severity: Keywords: sessions
Cc: ferringb@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

After 5482 appeared KeyError in django/contrib/sessions/middleware.py in _getitem_, line 20 with newforms

Attachments (1)

r5482.tar.gz (2.6 KB) - added by mtredinnick 7 years ago.
Example of problem (from original submitter)

Download all attachments as: .zip

Change History (7)

comment:1 Changed 7 years ago by boobsd@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from KeyError in sessions after changeset 5482 to KeyError in sessions after changeset 5482 with newforms

Because upload does not work, this is link to example django-project with KeyError:
http://vega-holding.ru/media/r5482.tar.gz

comment:2 Changed 7 years ago by mtredinnick

The domain name doesn't resolve for me, so I can't download the test case.

comment:3 Changed 7 years ago by mtredinnick

Okay, I've got it now.

comment:4 Changed 7 years ago by (removed)

  • Cc ferringb@… added

Changed 7 years ago by mtredinnick

Example of problem (from original submitter)

comment:5 Changed 7 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

(For anybody else looking at this, unpack the tarball, ensure SQLite is available and run syncdb then runserver and access localhost:8000/ and follow the instructions.)

This is not a bug in Django, as best I can understand it.

The code seems to be relying on the fact that the RegisterForm.__del__ method has been called at some point to set up self.session['expression_result']. You basically can't rely on __del__ being called at a predictable moment in Python. Any code that does that is likely to hit problems when another reference to the object is taken, for example. That is exactly what is happening in this case (an iterator somewhere is holding a reference).

The problem here is in the sample code making unjustified assumptions about execution order.

comment:6 Changed 7 years ago by boobsd@…

Why then only after changeset 5482 was appeared this error?

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.