Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19254 closed Bug (fixed)

clear_expired for Sessions With File Backend Throws Exception

Reported by: Simon Blanchard Owned by: nobody
Component: contrib.sessions Version: 1.5-alpha-1
Severity: Release blocker Keywords: sessions filebackend
Cc: bnomis@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The following line in clear_expired for file based sessions does not do what the author intended:

storage_path = getattr(settings, "SESSION_FILE_PATH", tempfile.gettempdir())

tempfile.gettempdir() will only be called if SESSION_FILE_PATH does not exist in settings. But it does exist and defaults to None. The exception occurs in the call os.listdir(storage_path).

What is probably required is this:

storage_path = getattr(settings, "SESSION_FILE_PATH", None)
if not storage_path:
    storage_path = tempfile.gettempdir()

or this:

storage_path = cls._get_storage_path()

Change History (5)

comment:1 by Claude Paroz, 12 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 by Simon Blanchard, 12 years ago

Cc: bnomis@… added

comment:3 by Aymeric Augustin, 12 years ago

Good catch — that's why I factored out _get_storage_path! And I forgot to use it in the final patch :(

This mistake wasn't caught because Django forces the value of SESSION_FILE_PATH in order to be able to clean up after the tests.

comment:4 by Aymeric Augustin <aymeric.augustin@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 93e0ec553dae73a2a86cb23b058414d8f9ae3bd6:

[1.5.x] Fixed #19254 -- Bug in SESSION_FILE_PATH handling.

Thanks simonb for the report.

Refs #18194.

Backport of 11fd00c from master.

comment:5 by Aymeric Augustin <aymeric.augustin@…>, 12 years ago

In 11fd00c46e2826ce5852e096487762a96909b717:

Fixed #19254 -- Bug in SESSION_FILE_PATH handling.

Thanks simonb for the report.

Refs #18194.

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