summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-07-21 10:01:46 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-08-07 12:00:22 +0200
commita8b3ddec5f05268b67b3efe6a7dc6accb1bac715 (patch)
treeff95a7e22eb6dcc3def77d824b890c0881185984
parentc5ef65bcf324f4c90b53be90f4aec069a68e8c59 (diff)
[py3] Applied minor fixes so the test suite starts
-rw-r--r--django/core/management/base.py4
-rw-r--r--django/db/models/base.py47
-rw-r--r--django/db/models/fields/__init__.py2
-rw-r--r--django/test/client.py4
4 files changed, 30 insertions, 27 deletions
diff --git a/django/core/management/base.py b/django/core/management/base.py
index a204f6f0bc..5e630d5207 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -6,7 +6,6 @@ be executed through ``django-admin.py`` or ``manage.py``).
import os
import sys
-from io import BytesIO
from optparse import make_option, OptionParser
import traceback
@@ -14,6 +13,7 @@ import django
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 @@ class BaseCommand(object):
"""
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)
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 4568430bfa..35ae2231d6 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -28,6 +28,30 @@ from django.utils import six
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)
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 2c738d6a20..2c38e8d72e 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -135,6 +135,8 @@ class Field(object):
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.
diff --git a/django/test/client.py b/django/test/client.py
index ef80a7129a..a9ae7f5db1 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -194,9 +194,9 @@ class RequestFactory(object):
'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,