Django

Code

Ticket #4613 (closed: invalid)

Opened 1 year ago

Last modified 1 year ago

KeyError in sessions after changeset 5482 with newforms

Reported by: boobsd@gmail.com Assigned to: adrian
Milestone: Component: Forms
Version: SVN Keywords: sessions
Cc: ferringb@gmail.com Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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

Attachments

r5482.tar.gz (2.6 kB) - added by mtredinnick on 06/18/07 19:29:59.
Example of problem (from original submitter)

Change History

06/18/07 10:05:35 changed by boobsd@gmail.com

  • needs_better_patch changed.
  • summary changed from KeyError in sessions after changeset 5482 to KeyError in sessions after changeset 5482 with newforms.
  • needs_tests changed.
  • needs_docs changed.

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

06/18/07 18:26:59 changed by mtredinnick

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

06/18/07 18:40:13 changed by mtredinnick

Okay, I've got it now.

06/18/07 19:01:33 changed by Brian Harring <ferringb@gmail.com>

  • cc set to ferringb@gmail.com.

06/18/07 19:29:59 changed by mtredinnick

  • attachment r5482.tar.gz added.

Example of problem (from original submitter)

06/18/07 19:34:00 changed by mtredinnick

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

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

06/19/07 03:47:06 changed by boobsd@gmail.com

Why then only after changeset 5482 was appeared this error?


Add/Change #4613 (KeyError in sessions after changeset 5482 with newforms)




Change Properties
Action