Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[py3] fixed session file backend.
  • Loading branch information
apollo13 committed Aug 15, 2012
1 parent 4d393e1 commit f2fff84
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/contrib/sessions/backends/file.py
Expand Up @@ -5,6 +5,7 @@
from django.conf import settings
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
from django.utils.encoding import smart_bytes


class SessionStore(SessionBase):
Expand Down Expand Up @@ -115,7 +116,7 @@ def save(self, must_create=False):
renamed = False
try:
try:
os.write(output_file_fd, self.encode(session_data))
os.write(output_file_fd, self.encode(session_data).encode())

This comment has been minimized.

Copy link
@dreynolds

dreynolds Jun 29, 2016

Is it possible to get an explanation of what this fixes exactly? The commit message is not totally clear and this line is causing some issues for me.

This comment has been minimized.

Copy link
@apollo13

apollo13 Jun 29, 2016

Author Member

We need to ensure that we write bytes

finally:
os.close(output_file_fd)
os.rename(output_file_name, session_file_name)
Expand Down

2 comments on commit f2fff84

@claudep
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the smart_bytes import is a remainder of trials?

@apollo13
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessed right, will fix it.

Please sign in to comment.