summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-09-09 19:33:40 +0000
committerJannis Leidel <jannis@leidel.info>2011-09-09 19:33:40 +0000
commitfb590bfa9bfdeb622677187552cae707f379c7b1 (patch)
treec830a4d72a15cb942f91054c0cbf9606af1712f0
parent7deb25b8dd5aa1ed02b5e30cbc67cd1fb0c3d6e6 (diff)
Replaced `has_key()` calls with `in` to ease Python 3 port. Thanks, Martin von Löwis.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16740 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/databrowse/plugins/calendars.py2
-rw-r--r--django/contrib/databrowse/plugins/fieldchoices.py2
-rw-r--r--django/contrib/sessions/backends/base.py2
-rw-r--r--django/contrib/sessions/backends/cache.py4
-rw-r--r--django/contrib/sessions/backends/file.py4
-rw-r--r--django/contrib/sessions/tests.py2
-rw-r--r--django/core/management/__init__.py2
-rw-r--r--django/http/__init__.py4
-rw-r--r--django/views/debug.py2
9 files changed, 10 insertions, 14 deletions
diff --git a/django/contrib/databrowse/plugins/calendars.py b/django/contrib/databrowse/plugins/calendars.py
index 4a9468e396..3416f88ca7 100644
--- a/django/contrib/databrowse/plugins/calendars.py
+++ b/django/contrib/databrowse/plugins/calendars.py
@@ -86,7 +86,7 @@ class CalendarPlugin(DatabrowsePlugin):
if url is None:
return self.homepage_view(request)
url_bits = url.split('/')
- if self.fields.has_key(url_bits[0]):
+ if url_bits[0] in self.fields:
return self.calendar_view(request, self.fields[url_bits[0]], *url_bits[1:])
raise http.Http404('The requested page does not exist.')
diff --git a/django/contrib/databrowse/plugins/fieldchoices.py b/django/contrib/databrowse/plugins/fieldchoices.py
index e0c01e95e6..b3210681e9 100644
--- a/django/contrib/databrowse/plugins/fieldchoices.py
+++ b/django/contrib/databrowse/plugins/fieldchoices.py
@@ -53,7 +53,7 @@ class FieldChoicePlugin(DatabrowsePlugin):
if url is None:
return self.homepage_view(request)
url_bits = url.split('/', 1)
- if self.fields.has_key(url_bits[0]):
+ if url_bits[0] in self.fields:
return self.field_view(request, self.fields[url_bits[0]], *url_bits[1:])
raise http.Http404('The requested page does not exist.')
diff --git a/django/contrib/sessions/backends/base.py b/django/contrib/sessions/backends/base.py
index 050ed7b69e..920b3e68cd 100644
--- a/django/contrib/sessions/backends/base.py
+++ b/django/contrib/sessions/backends/base.py
@@ -113,7 +113,7 @@ class SessionBase(object):
self.modified = True
def has_key(self, key):
- return self._session.has_key(key)
+ return key in self._session
def values(self):
return self._session.values()
diff --git a/django/contrib/sessions/backends/cache.py b/django/contrib/sessions/backends/cache.py
index ab0716dcb4..22c95b23d5 100644
--- a/django/contrib/sessions/backends/cache.py
+++ b/django/contrib/sessions/backends/cache.py
@@ -43,9 +43,7 @@ class SessionStore(SessionBase):
raise CreateError
def exists(self, session_key):
- if self._cache.has_key(session_key):
- return True
- return False
+ return session_key in self._cache
def delete(self, session_key=None):
if session_key is None:
diff --git a/django/contrib/sessions/backends/file.py b/django/contrib/sessions/backends/file.py
index 2c4e40dbc7..0c60fff389 100644
--- a/django/contrib/sessions/backends/file.py
+++ b/django/contrib/sessions/backends/file.py
@@ -131,9 +131,7 @@ class SessionStore(SessionBase):
pass
def exists(self, session_key):
- if os.path.exists(self._key_to_file(session_key)):
- return True
- return False
+ return os.path.exists(self._key_to_file(session_key))
def delete(self, session_key=None):
if session_key is None:
diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
index 2a4d6c8766..95e8e901a8 100644
--- a/django/contrib/sessions/tests.py
+++ b/django/contrib/sessions/tests.py
@@ -80,7 +80,7 @@ class SessionTestsMixin(object):
self.session['some key'] = 1
self.session.modified = False
self.session.accessed = False
- self.assertTrue(self.session.has_key('some key'))
+ self.assertTrue('some key' in self.session)
self.assertTrue(self.session.accessed)
self.assertFalse(self.session.modified)
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index 1345eaf66a..c66a0b0e29 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -283,7 +283,7 @@ class ManagementUtility(object):
and formatted as potential completion suggestions.
"""
# Don't complete if user hasn't sourced bash_completion file.
- if not os.environ.has_key('DJANGO_AUTO_COMPLETE'):
+ if 'DJANGO_AUTO_COMPLETE' not in os.environ:
return
cwords = os.environ['COMP_WORDS'].split()[1:]
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 3d928d9f5d..4f1cda7785 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -23,7 +23,7 @@ except ImportError:
import Cookie
# httponly support exists in Python 2.6's Cookie library,
# but not in Python 2.5.
-_morsel_supports_httponly = Cookie.Morsel._reserved.has_key('httponly')
+_morsel_supports_httponly = 'httponly' in Cookie.Morsel._reserved
# Some versions of Python 2.7 and later won't need this encoding bug fix:
_cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"')
# See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256
@@ -591,7 +591,7 @@ class HttpResponse(object):
def has_header(self, header):
"""Case-insensitive check for a header."""
- return self._headers.has_key(header.lower())
+ return header.lower() in self._headers
__contains__ = has_header
diff --git a/django/views/debug.py b/django/views/debug.py
index 69cea89812..6041930d62 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -141,7 +141,7 @@ class SafeExceptionReporterFilter(ExceptionReporterFilter):
else:
# Cleanse only the specified parameters.
for param in sensitive_post_parameters:
- if cleansed.has_key(param):
+ if param in cleansed:
cleansed[param] = CLEANSED_SUBSTITUTE
return cleansed
else: