Skip to content

Add support for Python 3 #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
eb0d02d
Add python 3.3 and 3.2 as allow_failures
graingert Apr 8, 2013
eb53791
add <1.6 to tests_require
graingert Apr 8, 2013
005ca0b
use sqlparse from pypi
graingert Apr 8, 2013
c73c77a
remove support for django <1.4.2
graingert Apr 8, 2013
c58094b
use new style exception in __init__.py
graingert Apr 8, 2013
e749ab1
port imports to py3k in middleware.py
graingert Apr 8, 2013
f6aad29
support new style exceptions in loader.py
graingert Apr 8, 2013
f1d5de5
port imports to py3k in utils/__init__.py
graingert Apr 8, 2013
61d1286
support new style exceptions in utils/tracking/__init__.py
graingert Apr 8, 2013
e4e8388
use force_text instead of force_unicode
graingert Apr 8, 2013
e3723e3
remove use of deprecated sqlparse.filters.Filters
graingert Apr 8, 2013
bab0aee
use thread from six.moves in tests/tests.py
graingert Apr 8, 2013
417c852
use assertEqual instead of assertEquals in tests
graingert Apr 8, 2013
3929d60
use iteritems from six, or items in templates
graingert Apr 8, 2013
068a6c1
use string_types from six instead of basestring
graingert Apr 8, 2013
7cb3cb0
use iterkeys and itervalues from six, or .keys and .values in templates
graingert Apr 8, 2013
c2485f5
deprecate functions unusable on Python3
graingert Apr 9, 2013
61bbd7f
use more simpler, more portable monkey_patch_call func in tracking
graingert Apr 9, 2013
cdfa803
use map from six
graingert Apr 9, 2013
494f421
force more things to bytes before hashing
graingert Apr 9, 2013
a30c83f
use text_type instead of unicode
graingert Apr 9, 2013
6e50c9f
add DJANGO_VERSION=1.5 to allow_failures
graingert Apr 9, 2013
47ea676
fix print function
w-diesel Apr 14, 2013
76a8159
Update profiling.py, attr. "func_closure" ( py2.6)
w-diesel Apr 14, 2013
f5d4cde
remove u'' prefix, import __future__ unicode_lit..
w-diesel Apr 14, 2013
0e6983a
use force_bytes to encode before hashing
graingert Apr 14, 2013
a088ed0
list expected
w-diesel Apr 14, 2013
3aa8c4c
Update middleware.py
w-diesel Apr 14, 2013
7a21c54
cache.py, fix python3.2 support
w-diesel Apr 15, 2013
fa40aa1
Masterbranch can pass all original tests on 1.5ver
w-diesel Apr 16, 2013
ee44437
Update .travis.yml
w-diesel Apr 16, 2013
fd2bb66
use unittest.skipIf to skip tests invalid on PY3
graingert Apr 23, 2013
09203c6
bump django version requirements to 1.4.5
graingert Apr 25, 2013
9a924cd
remove spaces from print functions
graingert Apr 25, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use iteritems from six, or items in templates
  • Loading branch information
graingert committed Apr 8, 2013
commit 3929d60c81431e4781027aa573ee6e3d40489a2e
3 changes: 2 additions & 1 deletion debug_toolbar/panels/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.template import Node
from django.utils.datastructures import SortedDict
from django.utils.translation import ugettext_lazy as _, ungettext
from django.utils.six import iteritems

from debug_toolbar.panels import DebugPanel
from debug_toolbar.utils import (tidy_stacktrace, render_stacktrace,
Expand Down Expand Up @@ -166,7 +167,7 @@ def _store_call_info(self, sender, name=None, time_taken=0,
else:
self.hits += 1
elif name == 'get_many':
for key, value in return_value.iteritems():
for key, value in iteritems(return_value):
if value is None:
self.misses += 1
else:
Expand Down
5 changes: 3 additions & 2 deletions debug_toolbar/panels/profiling.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import division

from django.utils.six import iteritems
from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe
from debug_toolbar.panels import DebugPanel
Expand All @@ -23,7 +24,7 @@ class DjangoDebugToolbarStats(Stats):

def get_root_func(self):
if self.__root is None:
for func, (cc, nc, tt, ct, callers) in self.stats.iteritems():
for func, (cc, nc, tt, ct, callers) in iteritems(self.stats):
if len(callers) == 0:
self.__root = func
break
Expand Down Expand Up @@ -80,7 +81,7 @@ def subfuncs(self):
i = 0
h, s, v = self.hsv
count = len(self.statobj.all_callees[self.func])
for func, stats in self.statobj.all_callees[self.func].iteritems():
for func, stats in iteritems(self.statobj.all_callees[self.func]):
i += 1
h1 = h + (i / count) / (self.depth + 1)
if stats[3] == 0:
Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/templates/debug_toolbar/panels/headers.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</tr>
</thead>
<tbody>
{% for key, value in headers.iteritems %}
{% for key, value in headers.items %}
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
<td>{{ key|escape }}</td>
<td>{{ value|escape }}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h4>{% blocktrans count templates|length as template_count %}Template{% plural %
<h4>{% blocktrans count context_processors|length as context_processors_count %}Context processor{% plural %}Context processors{% endblocktrans %}</h4>
{% if context_processors %}
<dl>
{% for key, value in context_processors.iteritems %}
{% for key, value in context_processors.items %}
<dt><strong>{{ key|escape }}</strong></dt>
<dd>
<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext"><span class="toggleArrow">&#x25B6;</span> {% trans 'Toggle Context' %}</a></div>
Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/templates/debug_toolbar/panels/versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</tr>
</thead>
<tbody>
{% for package, version in versions.iteritems %}
{% for package, version in versions.items %}
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
<td>{{ package }}</td>
<td>{{ version }}</td>
Expand Down
3 changes: 2 additions & 1 deletion debug_toolbar/utils/tracking/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.conf import settings
from django.template import Node
from django.utils.encoding import force_text, smart_str
from django.utils.six import iteritems

from debug_toolbar.utils import ms_from_timedelta, tidy_stacktrace, \
get_template_info, get_stack
Expand Down Expand Up @@ -88,7 +89,7 @@ def _quote_expr(self, element):
def _quote_params(self, params):
if isinstance(params, dict):
return dict((key, self._quote_expr(value))
for key, value in params.iteritems())
for key, value in iteritems(params))
return map(self._quote_expr, params)

def _decode(self, param):
Expand Down
5 changes: 3 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import with_statement
from django.utils.six.moves import _thread
from django.utils.six import iteritems

from django.conf import settings
from django.contrib.auth.models import User
Expand Down Expand Up @@ -30,12 +31,12 @@ def __init__(self, **overrides):
self._orig = {}

def __enter__(self):
for k, v in self.overrides.iteritems():
for k, v in iteritems(self.overrides):
self._orig[k] = getattr(settings, k, self.NotDefined)
setattr(settings, k, v)

def __exit__(self, exc_type, exc_value, traceback):
for k, v in self._orig.iteritems():
for k, v in iteritems(self._orig):
if v is self.NotDefined:
delattr(settings, k)
else:
Expand Down