Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#4613 closed (invalid)

KeyError in sessions after changeset 5482 with newforms

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

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 Malcolm Tredinnick 17 years ago.
Example of problem (from original submitter)

Download all attachments as: .zip

Change History (7)

comment:1 by boobsd@…, 17 years ago

Summary: KeyError in sessions after changeset 5482KeyError 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 by Malcolm Tredinnick, 17 years ago

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

comment:3 by Malcolm Tredinnick, 17 years ago

Okay, I've got it now.

comment:4 by (removed), 17 years ago

Cc: ferringb@… added

by Malcolm Tredinnick, 17 years ago

Attachment: r5482.tar.gz added

Example of problem (from original submitter)

comment:5 by Malcolm Tredinnick, 17 years ago

Resolution: invalid
Status: newclosed

(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 by boobsd@…, 17 years ago

Why then only after changeset 5482 was appeared this error?

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