﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20308	File session backend does not work in Windows	Martin Larente	nobody	"The file session backend does not work at all in Windows. The culprit is this code in `django.contrib.sessions.backends.file.SessionStore.save()`:

{{{
    try:
        try:
            os.write(output_file_fd, self.encode(session_data).encode())
        finally:
            os.close(output_file_fd)
        os.rename(output_file_name, session_file_name)
        renamed = True
    finally:
        if not renamed:
            os.unlink(output_file_name)
}}}

The `os.rename` call cannot be used to replace a file directly in Windows ( http://docs.python.org/2/library/os.html#os.rename ). The result is that the files saved by the backends are always empty.

I understand that Windows file handling might not be suited to use the file session backend. However, what's annoying is that it makes a test fail as well, even if I don't use the backend:

{{{
FAIL: test_clearsessions_command (django.contrib.sessions.tests.FileSessionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""C:\[...]\site-packages\django\test\utils.py"", line 220, in inner
    return test_func(*args, **kwargs)
  File ""C:\[...]\site-packages\django\contrib\sessions\tests.py"", line 444, in test_clearsessions_command
    self.assertEqual(1, count_sessions())
AssertionError: 1 != 2
}}}

I think this bug should either be fixed or the test be changed to be skipped in Windows (and the documentation should also mention that the file backend cannot be used in Windows)."	Bug	closed	contrib.sessions	1.5	Normal	duplicate			Unreviewed	0	0	0	0	0	0
