Permalink
Browse files

[py3] fixed session file backend.

  • Loading branch information...
1 parent 4d393e1 commit f2fff84bc3e85b9c9c132dec614e8b293df8f6bb @apollo13 apollo13 committed Aug 15, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 django/contrib/sessions/backends/file.py
@@ -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):
@@ -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())
@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.

@apollo13

apollo13 Jun 29, 2016

Owner

We need to ensure that we write bytes

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

2 comments on commit f2fff84

Member

claudep commented on f2fff84 Aug 15, 2012

I guess the smart_bytes import is a remainder of trials?

Owner

apollo13 replied Aug 15, 2012

Guessed right, will fix it.

Please sign in to comment.