summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-09-02 12:06:32 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-09-02 12:11:02 +0200
commit365c3e8b73eab825a8ecd0cf8046e1a0824ccd45 (patch)
treef22f78037da5fa34250851e1dace72c4b2e77e78 /django
parent4292097078279226cb725c2921011fb14634b9af (diff)
Replaced "not PY3" by "PY2", new in six 1.4.0.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/auth/management/__init__.py2
-rw-r--r--django/contrib/auth/tests/test_basic.py4
-rw-r--r--django/core/mail/message.py2
-rw-r--r--django/db/backends/mysql/base.py2
-rw-r--r--django/db/backends/oracle/base.py6
-rw-r--r--django/db/backends/sqlite3/base.py2
-rw-r--r--django/db/models/base.py4
-rw-r--r--django/http/cookie.py2
-rw-r--r--django/template/loaders/app_directories.py4
-rw-r--r--django/template/loaders/eggs.py2
-rw-r--r--django/utils/_os.py6
-rw-r--r--django/utils/encoding.py2
-rw-r--r--django/utils/feedgenerator.py4
-rw-r--r--django/utils/functional.py2
-rw-r--r--django/utils/http.py4
-rw-r--r--django/utils/text.py2
16 files changed, 25 insertions, 25 deletions
diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
index 74d0909587..c53d581858 100644
--- a/django/contrib/auth/management/__init__.py
+++ b/django/contrib/auth/management/__init__.py
@@ -142,7 +142,7 @@ def get_system_username():
# if there is no corresponding entry in the /etc/passwd file
# (a very restricted chroot environment, for example).
return ''
- if not six.PY3:
+ if six.PY2:
try:
result = result.decode(DEFAULT_LOCALE_ENCODING)
except UnicodeDecodeError:
diff --git a/django/contrib/auth/tests/test_basic.py b/django/contrib/auth/tests/test_basic.py
index 6b1dd3af05..8dc9af5d85 100644
--- a/django/contrib/auth/tests/test_basic.py
+++ b/django/contrib/auth/tests/test_basic.py
@@ -16,7 +16,7 @@ from django.test.signals import setting_changed
from django.test.utils import override_settings
from django.utils import translation
from django.utils.encoding import force_str
-from django.utils.six import binary_type, PY3, StringIO
+from django.utils.six import binary_type, PY2, StringIO
@receiver(setting_changed)
@@ -39,7 +39,7 @@ def mock_inputs(inputs):
class mock_getpass:
@staticmethod
def getpass(prompt=b'Password: ', stream=None):
- if not PY3:
+ if PY2:
# getpass on Windows only supports prompt as bytestring (#19807)
assert isinstance(prompt, binary_type)
return inputs['password']
diff --git a/django/core/mail/message.py b/django/core/mail/message.py
index a24817ac90..2f24688d42 100644
--- a/django/core/mail/message.py
+++ b/django/core/mail/message.py
@@ -366,7 +366,7 @@ class EmailMessage(object):
try:
filename.encode('ascii')
except UnicodeEncodeError:
- if not six.PY3:
+ if six.PY2:
filename = filename.encode('utf-8')
filename = ('utf-8', '', filename)
attachment.add_header('Content-Disposition', 'attachment',
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 6483b97deb..92438ee91c 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -420,7 +420,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
'conv': django_conversions,
'charset': 'utf8',
}
- if not six.PY3:
+ if six.PY2:
kwargs['use_unicode'] = True
settings_dict = self.settings_dict
if settings_dict['USER']:
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index a6ff26dd36..1323a325c7 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -276,7 +276,7 @@ WHEN (new.%(col_name)s IS NULL)
# http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.statement
# The DB API definition does not define this attribute.
statement = cursor.statement
- if statement and not six.PY3 and not isinstance(statement, unicode):
+ if statement and six.PY2 and not isinstance(statement, unicode):
statement = statement.decode('utf-8')
# Unlike Psycopg's `query` and MySQLdb`'s `_last_executed`, CxOracle's
# `statement` doesn't contain the query parameters. refs #20010.
@@ -585,7 +585,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
cursor.execute("SELECT 1 FROM DUAL WHERE DUMMY %s"
% self._standard_operators['contains'],
['X'])
- except DatabaseError:
+ except DatabaseError:
self.operators = self._likec_operators
else:
self.operators = self._standard_operators
@@ -627,7 +627,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
and x.code == 2091 and 'ORA-02291' in x.message:
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
raise
-
+
def schema_editor(self):
"Returns a new instance of this backend's SchemaEditor"
return DatabaseSchemaEditor(self)
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index c6cda55229..385733cb8d 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -84,7 +84,7 @@ Database.register_converter(str("decimal"), decoder(util.typecast_decimal))
Database.register_adapter(datetime.datetime, adapt_datetime_with_timezone_support)
Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal)
-if not six.PY3:
+if six.PY2:
Database.register_adapter(str, lambda s: s.decode('utf-8'))
Database.register_adapter(SafeBytes, lambda s: s.decode('utf-8'))
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 259d597636..2ca6f3ecc2 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -264,7 +264,7 @@ class ModelBase(type):
return new_class
new_class._prepare()
-
+
new_class._meta.app_cache.register_models(new_class._meta.app_label, new_class)
# Because of the way imports happen (recursively), we may or may not be
# the first time this model tries to register with the framework. There
@@ -449,7 +449,7 @@ class Model(six.with_metaclass(ModelBase)):
return force_str('<%s: %s>' % (self.__class__.__name__, u))
def __str__(self):
- if not six.PY3 and hasattr(self, '__unicode__'):
+ if six.PY2 and hasattr(self, '__unicode__'):
if type(self).__unicode__ == Model.__str__:
klass_name = type(self).__name__
raise RuntimeError("%s.__unicode__ is aliased to __str__. Did"
diff --git a/django/http/cookie.py b/django/http/cookie.py
index 62d5c61a4d..40cf58def8 100644
--- a/django/http/cookie.py
+++ b/django/http/cookie.py
@@ -49,7 +49,7 @@ else:
if not _cookie_allows_colon_in_names:
def load(self, rawdata):
self.bad_cookies = set()
- if not six.PY3 and isinstance(rawdata, six.text_type):
+ if six.PY2 and isinstance(rawdata, six.text_type):
rawdata = force_str(rawdata)
super(SimpleCookie, self).load(rawdata)
for key in self.bad_cookies:
diff --git a/django/template/loaders/app_directories.py b/django/template/loaders/app_directories.py
index b25f14aace..44983065e4 100644
--- a/django/template/loaders/app_directories.py
+++ b/django/template/loaders/app_directories.py
@@ -15,7 +15,7 @@ from django.utils._os import safe_join
from django.utils import six
# At compile time, cache the directories to search.
-if not six.PY3:
+if six.PY2:
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
app_template_dirs = []
for app in settings.INSTALLED_APPS:
@@ -25,7 +25,7 @@ for app in settings.INSTALLED_APPS:
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
if os.path.isdir(template_dir):
- if not six.PY3:
+ if six.PY2:
template_dir = template_dir.decode(fs_encoding)
app_template_dirs.append(template_dir)
diff --git a/django/template/loaders/eggs.py b/django/template/loaders/eggs.py
index b7dcc75be3..7da180323a 100644
--- a/django/template/loaders/eggs.py
+++ b/django/template/loaders/eggs.py
@@ -27,7 +27,7 @@ class Loader(BaseLoader):
resource = resource_string(app, pkg_name)
except Exception:
continue
- if not six.PY3:
+ if six.PY2:
resource = resource.decode(settings.FILE_CHARSET)
return (resource, 'egg:%s:%s' % (app, pkg_name))
raise TemplateDoesNotExist(template_name)
diff --git a/django/utils/_os.py b/django/utils/_os.py
index 607e02c94d..3e60c1082c 100644
--- a/django/utils/_os.py
+++ b/django/utils/_os.py
@@ -12,7 +12,7 @@ except NameError:
class WindowsError(Exception):
pass
-if not six.PY3:
+if six.PY2:
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
@@ -38,7 +38,7 @@ def upath(path):
"""
Always return a unicode path.
"""
- if not six.PY3 and not isinstance(path, six.text_type):
+ if six.PY2 and not isinstance(path, six.text_type):
return path.decode(fs_encoding)
return path
@@ -47,7 +47,7 @@ def npath(path):
Always return a native path, that is unicode on Python 3 and bytestring on
Python 2.
"""
- if not six.PY3 and not isinstance(path, bytes):
+ if six.PY2 and not isinstance(path, bytes):
return path.encode(fs_encoding)
return path
diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index aa0218ca6b..bb7c38fea8 100644
--- a/django/utils/encoding.py
+++ b/django/utils/encoding.py
@@ -30,7 +30,7 @@ def python_2_unicode_compatible(klass):
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 not six.PY3:
+ if six.PY2:
klass.__unicode__ = klass.__str__
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
return klass
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index de32b9f8cc..3aa6b2cb23 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -46,7 +46,7 @@ def rfc2822_date(date):
dow = days[date.weekday()]
month = months[date.month - 1]
time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month))
- if not six.PY3: # strftime returns a byte string in Python 2
+ if six.PY2: # strftime returns a byte string in Python 2
time_str = time_str.decode('utf-8')
if is_aware(date):
offset = date.tzinfo.utcoffset(date)
@@ -60,7 +60,7 @@ def rfc3339_date(date):
# Support datetime objects older than 1900
date = datetime_safe.new_datetime(date)
time_str = date.strftime('%Y-%m-%dT%H:%M:%S')
- if not six.PY3: # strftime returns a byte string in Python 2
+ if six.PY2: # strftime returns a byte string in Python 2
time_str = time_str.decode('utf-8')
if is_aware(date):
offset = date.tzinfo.utcoffset(date)
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 9cc703fe84..bfd59e5340 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -167,7 +167,7 @@ def lazy(func, *resultclasses):
return hash(self.__cast())
def __mod__(self, rhs):
- if self._delegate_bytes and not six.PY3:
+ if self._delegate_bytes and six.PY2:
return bytes(self) % rhs
elif self._delegate_text:
return six.text_type(self) % rhs
diff --git a/django/utils/http.py b/django/utils/http.py
index 9b36ab91d7..a751dea3c6 100644
--- a/django/utils/http.py
+++ b/django/utils/http.py
@@ -170,7 +170,7 @@ def base36_to_int(s):
value = int(s, 36)
# ... then do a final check that the value will fit into an int to avoid
# returning a long (#15067). The long type was removed in Python 3.
- if not six.PY3 and value > sys.maxint:
+ if six.PY2 and value > sys.maxint:
raise ValueError("Base36 input too large")
return value
@@ -182,7 +182,7 @@ def int_to_base36(i):
factor = 0
if i < 0:
raise ValueError("Negative base36 conversion input.")
- if not six.PY3:
+ if six.PY2:
if not isinstance(i, six.integer_types):
raise TypeError("Non-integer base36 conversion input.")
if i > sys.maxint:
diff --git a/django/utils/text.py b/django/utils/text.py
index e89f7df0c6..eeff5c5a2e 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -12,7 +12,7 @@ from django.utils.six.moves import html_entities
from django.utils.translation import ugettext_lazy, ugettext as _, pgettext
from django.utils.safestring import mark_safe
-if not six.PY3:
+if six.PY2:
# Import force_unicode even though this module doesn't use it, because some
# people rely on it being here.
from django.utils.encoding import force_unicode