Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Applied minor fixes so the test suite starts

  • Loading branch information...
commit a8b3ddec5f05268b67b3efe6a7dc6accb1bac715 1 parent c5ef65b
@aaugustin aaugustin authored
View
4 django/core/management/base.py
@@ -6,7 +6,6 @@
import os
import sys
-from io import BytesIO
from optparse import make_option, OptionParser
import traceback
@@ -14,6 +13,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.core.management.color import color_style
from django.utils.encoding import smart_str
+from django.utils.six import StringIO
class CommandError(Exception):
@@ -273,7 +273,7 @@ def validate(self, app=None, display_num_errors=False):
"""
from django.core.management.validation import get_validation_errors
- s = BytesIO()
+ s = StringIO()
num_errors = get_validation_errors(s, app)
if num_errors:
s.seek(0)
View
47 django/db/models/base.py
@@ -28,6 +28,30 @@
from django.utils.text import get_text_list, capfirst
+def subclass_exception(name, parents, module, attached_to=None):
+ """
+ Create exception subclass. Used by ModelBase below.
+
+ If 'attached_to' is supplied, the exception will be created in a way that
+ allows it to be pickled, assuming the returned exception class will be added
+ as an attribute to the 'attached_to' class.
+ """
+ class_dict = {'__module__': module}
+ if attached_to is not None:
+ def __reduce__(self):
+ # Exceptions are special - they've got state that isn't
+ # in self.__dict__. We assume it is all in self.args.
+ return (unpickle_inner_exception, (attached_to, name), self.args)
+
+ def __setstate__(self, args):
+ self.args = args
+
+ class_dict['__reduce__'] = __reduce__
+ class_dict['__setstate__'] = __setstate__
+
+ return type(name, parents, class_dict)
+
+
class ModelBase(type):
"""
Metaclass for all models.
@@ -929,29 +953,6 @@ def model_unpickle(model, attrs):
return cls.__new__(cls)
model_unpickle.__safe_for_unpickle__ = True
-def subclass_exception(name, parents, module, attached_to=None):
- """
- Create exception subclass.
-
- If 'attached_to' is supplied, the exception will be created in a way that
- allows it to be pickled, assuming the returned exception class will be added
- as an attribute to the 'attached_to' class.
- """
- class_dict = {'__module__': module}
- if attached_to is not None:
- def __reduce__(self):
- # Exceptions are special - they've got state that isn't
- # in self.__dict__. We assume it is all in self.args.
- return (unpickle_inner_exception, (attached_to, name), self.args)
-
- def __setstate__(self, args):
- self.args = args
-
- class_dict['__reduce__'] = __reduce__
- class_dict['__setstate__'] = __setstate__
-
- return type(name, parents, class_dict)
-
def unpickle_inner_exception(klass, exception_name):
# Get the exception class from the class it is attached to:
exception = getattr(klass, exception_name)
View
2  django/db/models/fields/__init__.py
@@ -135,6 +135,8 @@ def __lt__(self, other):
return self.creation_counter < other.creation_counter
return NotImplemented
+ __hash__ = object.__hash__
+
def __deepcopy__(self, memodict):
# We don't have to deepcopy very much here, since most things are not
# intended to be altered after initial creation.
View
4 django/test/client.py
@@ -194,9 +194,9 @@ def _base_environ(self, **request):
'SERVER_NAME': 'testserver',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
- 'wsgi.version': (1,0),
+ 'wsgi.version': (1, 0),
'wsgi.url_scheme': 'http',
- 'wsgi.input': FakePayload(''),
+ 'wsgi.input': FakePayload(b''),
'wsgi.errors': self.errors,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
Please sign in to comment.
Something went wrong with that request. Please try again.