Opened 16 years ago

Closed 16 years ago

Last modified 16 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 16 years ago.
Example of problem (from original submitter)

Download all attachments as: .zip

Change History (7)

comment:1 Changed 16 years ago by boobsd@…

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 Changed 16 years ago by Malcolm Tredinnick

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

comment:3 Changed 16 years ago by Malcolm Tredinnick

Okay, I've got it now.

comment:4 Changed 16 years ago by (removed)

Cc: ferringb@… added

Changed 16 years ago by Malcolm Tredinnick

Attachment: r5482.tar.gz added

Example of problem (from original submitter)

comment:5 Changed 16 years ago by Malcolm Tredinnick

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 Changed 16 years ago by boobsd@…

Why then only after changeset 5482 was appeared this error?

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