summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-01-05 13:13:34 -0500
committerTim Graham <timograham@gmail.com>2015-01-05 13:41:06 -0500
commit2fd8054fda5b8ec304d675f82f4bd80c16e3fd95 (patch)
tree0bf0ef738637720228a3fc058d7daa869acbd349
parent032ffade8acf6f79ff4cc7632d10df4619c32b72 (diff)
[1.4.x] Fixed #24081 -- Downgraded six to 1.8.0.
This reverts commit a25c444bc701b496f2b05f57fc3ec42cdac9dd85. six 1.9+ requires Python 2.6 so this commit restores Python 2.5 compatibility.
-rw-r--r--django/utils/six.py104
-rw-r--r--docs/releases/1.4.18.txt14
-rw-r--r--docs/releases/index.txt1
3 files changed, 35 insertions, 84 deletions
diff --git a/django/utils/six.py b/django/utils/six.py
index 8bd322ebdc..521a384d83 100644
--- a/django/utils/six.py
+++ b/django/utils/six.py
@@ -1,6 +1,6 @@
"""Utilities for writing code that runs on Python 2 and 3"""
-# Copyright (c) 2010-2015 Benjamin Peterson
+# Copyright (c) 2010-2014 Benjamin Peterson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -23,13 +23,12 @@
from __future__ import absolute_import
import functools
-import itertools
import operator
import sys
import types
__author__ = "Benjamin Peterson <benjamin@python.org>"
-__version__ = "1.9.0"
+__version__ = "1.8.0"
# Useful for very coarse version differentiation.
@@ -89,12 +88,8 @@ class _LazyDescr(object):
def __get__(self, obj, tp):
result = self._resolve()
setattr(obj, self.name, result) # Invokes __set__.
- try:
- # This is a bit ugly, but it avoids running this again by
- # removing this descriptor.
- delattr(obj.__class__, self.name)
- except AttributeError:
- pass
+ # This is a bit ugly, but it avoids running this again.
+ delattr(obj.__class__, self.name)
return result
@@ -559,12 +554,6 @@ if PY3:
def iterlists(d, **kw):
return iter(d.lists(**kw))
-
- viewkeys = operator.methodcaller("keys")
-
- viewvalues = operator.methodcaller("values")
-
- viewitems = operator.methodcaller("items")
else:
def iterkeys(d, **kw):
return iter(d.iterkeys(**kw))
@@ -578,12 +567,6 @@ else:
def iterlists(d, **kw):
return iter(d.iterlists(**kw))
- viewkeys = operator.methodcaller("viewkeys")
-
- viewvalues = operator.methodcaller("viewvalues")
-
- viewitems = operator.methodcaller("viewitems")
-
_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
_add_doc(iteritems,
@@ -610,9 +593,6 @@ if PY3:
import io
StringIO = io.StringIO
BytesIO = io.BytesIO
- _assertCountEqual = "assertCountEqual"
- _assertRaisesRegex = "assertRaisesRegex"
- _assertRegex = "assertRegex"
else:
def b(s):
return s
@@ -625,28 +605,14 @@ else:
return ord(bs[0])
def indexbytes(buf, i):
return ord(buf[i])
- iterbytes = functools.partial(itertools.imap, ord)
+ def iterbytes(buf):
+ return (ord(byte) for byte in buf)
import StringIO
StringIO = BytesIO = StringIO.StringIO
- _assertCountEqual = "assertItemsEqual"
- _assertRaisesRegex = "assertRaisesRegexp"
- _assertRegex = "assertRegexpMatches"
_add_doc(b, """Byte literal""")
_add_doc(u, """Text literal""")
-def assertCountEqual(self, *args, **kwargs):
- return getattr(self, _assertCountEqual)(*args, **kwargs)
-
-
-def assertRaisesRegex(self, *args, **kwargs):
- return getattr(self, _assertRaisesRegex)(*args, **kwargs)
-
-
-def assertRegex(self, *args, **kwargs):
- return getattr(self, _assertRegex)(*args, **kwargs)
-
-
if PY3:
exec_ = getattr(moves.builtins, "exec")
@@ -677,21 +643,6 @@ else:
""")
-if sys.version_info[:2] == (3, 2):
- exec_("""def raise_from(value, from_value):
- if from_value is None:
- raise value
- raise value from from_value
-""")
-elif sys.version_info[:2] > (3, 2):
- exec_("""def raise_from(value, from_value):
- raise value from from_value
-""")
-else:
- def raise_from(value, from_value):
- raise value
-
-
print_ = getattr(moves.builtins, "print", None)
if print_ is None:
def print_(*args, **kwargs):
@@ -746,14 +697,6 @@ if print_ is None:
write(sep)
write(arg)
write(end)
-if sys.version_info[:2] < (3, 3):
- _print = print_
- def print_(*args, **kwargs):
- fp = kwargs.get("file", sys.stdout)
- flush = kwargs.pop("flush", False)
- _print(*args, **kwargs)
- if flush and fp is not None:
- fp.flush()
_add_doc(reraise, """Reraise an exception.""")
@@ -761,7 +704,7 @@ if sys.version_info[0:2] < (3, 4):
def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
updated=functools.WRAPPER_UPDATES):
def wrapper(f):
- f = functools.wraps(wrapped, assigned, updated)(f)
+ f = functools.wraps(wrapped)(f)
f.__wrapped__ = wrapped
return f
return wrapper
@@ -794,25 +737,6 @@ def add_metaclass(metaclass):
return metaclass(cls.__name__, cls.__bases__, orig_vars)
return wrapper
-
-def python_2_unicode_compatible(klass):
- """
- A decorator that defines __unicode__ and __str__ methods under Python 2.
- Under Python 3 it does nothing.
-
- To support Python 2 and 3 with a single code base, define a __str__ method
- returning text and apply this decorator to the class.
- """
- if PY2:
- if '__str__' not in klass.__dict__:
- raise ValueError("@python_2_unicode_compatible cannot be applied "
- "to %s because it doesn't define __str__()." %
- klass.__name__)
- klass.__unicode__ = klass.__str__
- klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
- return klass
-
-
# Complete the moves implementation.
# This code is at the end of this module to speed up module loading.
# Turn this module into a package.
@@ -841,12 +765,24 @@ sys.meta_path.append(_importer)
### Additional customizations for Django ###
if PY3:
+ _assertRaisesRegex = "assertRaisesRegex"
+ _assertRegex = "assertRegex"
memoryview = memoryview
else:
- # memoryview and buffer are not strictly equivalent, but should be fine for
+ _assertRaisesRegex = "assertRaisesRegexp"
+ _assertRegex = "assertRegexpMatches"
+ # memoryview and buffer are not stricly equivalent, but should be fine for
# django core usage (mainly BinaryField). However, Jython doesn't support
# buffer (see http://bugs.jython.org/issue1521), so we have to be careful.
if sys.platform.startswith('java'):
memoryview = memoryview
else:
memoryview = buffer
+
+
+def assertRaisesRegex(self, *args, **kwargs):
+ return getattr(self, _assertRaisesRegex)(*args, **kwargs)
+
+
+def assertRegex(self, *args, **kwargs):
+ return getattr(self, _assertRegex)(*args, **kwargs)
diff --git a/docs/releases/1.4.18.txt b/docs/releases/1.4.18.txt
new file mode 100644
index 0000000000..f328be24c3
--- /dev/null
+++ b/docs/releases/1.4.18.txt
@@ -0,0 +1,14 @@
+===========================
+Django 1.4.18 release notes
+===========================
+
+*Under development*
+
+Django 1.4.18 fixes a regression on Python 2.5 in the 1.4.17 release.
+
+Bugfixes
+========
+
+* To maintain compatibility with Python 2.5, Django's vendored version of six,
+ :mod:`django.utils.six`, has been downgraded to 1.8.0 which is the last
+ version to support Python 2.5.
diff --git a/docs/releases/index.txt b/docs/releases/index.txt
index 7c598a5388..98f69adc20 100644
--- a/docs/releases/index.txt
+++ b/docs/releases/index.txt
@@ -19,6 +19,7 @@ Final releases
.. toctree::
:maxdepth: 1
+ 1.4.18
1.4.17
1.4.16
1.4.15