1. fiji
  2. django-3k


g8tam  committed 4395bad

Re-fixed builtin_server for the third time, set the assert in write to expect "bytes". Additionally removed errors in comment_tests by making sure sha_constructor gets fed "bytes".

  • Participants
  • Parent commits cbf2ed5
  • Branches default

Comments (0)

Files changed (2)

File django/contrib/comments/forms.py

View file
  • Ignore whitespace
 import time
 import datetime
+import sys
 from django import forms
 from django.forms.util import ErrorDict
 from django.conf import settings
 from django.contrib.contenttypes.models import ContentType
-from models import Comment
+from .models import Comment
 from django.utils.encoding import force_unicode
 from django.utils.hashcompat import sha_constructor
 from django.utils.text import get_text_list
     def generate_security_hash(self, content_type, object_pk, timestamp):
         """Generate a (SHA1) security hash from the provided info."""
         info = (content_type, object_pk, timestamp, settings.SECRET_KEY)
-        return sha_constructor("".join(info)).hexdigest()
+        if sys.version_info[0] < 3:
+            return sha_constructor("".join(info)).hexdigest()
+        else:
+            return sha_constructor("".join(info).encode('ascii')).hexdigest()
 class CommentDetailsForm(CommentSecurityForm):

File django/core/servers/basehttp.py

View file
  • Ignore whitespace
         if sys.version_info < (3,0):
             assert isinstance(data, bytes), "write() argument must be string"
-            assert isinstance(data, str), "write() argument must be string"
+            assert isinstance(data, bytes), "write() argument must be string"
         if not self.status:
             raise AssertionError("write() before start_response()")