Skip to content
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

Python 2/3 port: stage2: all tests passing with Django 1.5.8 on Python 3.3 and Python 2.6/2.7. #813

Merged
merged 36 commits into from
Nov 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7d01358
Python 2/3 port: result of ``futurize --stage2``
edschofield Nov 4, 2013
63feafc
Remove more redundant list() calls in loops
edschofield Nov 4, 2013
a463220
Python 2/3 port: be conservative: no magic super() imports
edschofield Nov 4, 2013
1a535a6
Put __future__ imports below the # encoding: utf-8 lines
edschofield Nov 4, 2013
4d827a8
Fall back to Python 2 urllib imports if needed
edschofield Nov 6, 2013
2b21bd9
Remove obsolete with_statement import from __future__
edschofield Nov 6, 2013
c44b64b
Always pass a native string to first arg of 3-arg type() call in midd…
edschofield Nov 6, 2013
543470e
Add absolute_import to prevent implicit relative import of html.py on…
edschofield Nov 6, 2013
bfdf817
Python 2/3 compatibility for types in the settings registry
edschofield Nov 6, 2013
ab355a0
Fix a few out-of-order __future__ imports
edschofield Nov 6, 2013
bb309a6
Python 3 compatibility: Use Django's newer smart_text and force_text …
edschofield Nov 6, 2013
2ca5503
Python 3: fix arg_names lookup in FormForForm.__init__
edschofield Nov 6, 2013
4dee3b7
Add Python 3.3 to .travis.yml
edschofield Nov 6, 2013
6b12afd
Python 3 compatibility: Fix galleries/models.py: use BytesIO etc.
edschofield Nov 6, 2013
6d1d0cb
Revert "Add Python 3.3 to .travis.yml"
edschofield Nov 6, 2013
9546376
PEP 8 style fixes
edschofield Nov 6, 2013
8f4c56b
Change __unicode__ -> __str__ and add python_2_unicode_compatible dec…
edschofield Nov 6, 2013
09272e4
Disable standard_library import hooks for pychecker
edschofield Nov 6, 2013
e2bc79d
Add future == 0.8.2 to requirements; remove dependency for setup.py
edschofield Nov 6, 2013
53bcc2f
Change future dependency to >= 0.8.2
edschofield Nov 6, 2013
7ec0505
Add Python 3.3 back to .travis.yml and disable tests on Py3.3 + Djang…
edschofield Nov 6, 2013
01e5679
Fix location of urlparse on Python 2
edschofield Nov 6, 2013
4db72f1
Add Python 3 classifier for PyPI
edschofield Nov 6, 2013
94c9d89
Prevent UnicodeDecodeError in test run on Py2 if files in the local d…
edschofield Nov 6, 2013
2fa0da7
Python 3: import local_settings correctly from project_template.settings
edschofield Nov 6, 2013
df47e14
Clean up imports
edschofield Nov 6, 2013
7ef3718
Work around Django / Python 2.x not supporting unicode cookie keys
edschofield Nov 7, 2013
5b76370
Change Py3-incompatible is-this-a-string type-check hack in send_mail…
edschofield Nov 7, 2013
93da64a
Fix for mezzanine.utils.email imports
edschofield Nov 7, 2013
5d464fa
Remove Django 1.4.x from .travis.yml for pull request for early testing
edschofield Nov 7, 2013
a622824
import_rss and import_tumblr scripts: fix urllib imports on Py2
edschofield Nov 7, 2013
bd50c5f
Clean up imports
edschofield Nov 8, 2013
c4b9889
Remove all isinstance() imports (with future v0.9)
edschofield Nov 12, 2013
7ffe717
Bump future version requirement to 0.9.0
edschofield Nov 15, 2013
9e55f45
Add Django 1.4.8 back to .travis.yml and disable tests on Py3.3 + Dja…
edschofield Nov 15, 2013
b8ab11b
Remove some unnecessary list() calls around map() results
edschofield Nov 15, 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
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ env:
python:
- "2.6"
- "2.7"
- "3.3"
matrix:
exclude:
- python: "3.3"
env: DJANGO_VERSION=1.4.8
install:
- pip install django==$DJANGO_VERSION --use-mirrors
- pip install . --use-mirrors
Expand Down
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

from __future__ import unicode_literals

import sys
import os

Expand Down
1 change: 1 addition & 0 deletions mezzanine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from __future__ import unicode_literals

__version__ = "1.4.16"
1 change: 1 addition & 0 deletions mezzanine/accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
setting. Some utility functions for probing the profile model are
included below.
"""
from __future__ import unicode_literals

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
Expand Down
1 change: 1 addition & 0 deletions mezzanine/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.contrib import admin

Expand Down
1 change: 1 addition & 0 deletions mezzanine/accounts/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
that are only read during startup shouldn't be editable, since changing
them would require an application reload.
"""
from __future__ import unicode_literals

from django.utils.translation import ugettext_lazy as _

Expand Down
1 change: 1 addition & 0 deletions mezzanine/accounts/forms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.contrib.auth import authenticate
from django.db.models import Q
Expand Down
2 changes: 2 additions & 0 deletions mezzanine/accounts/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
from future.builtins import str

from django.db import connection
from django.db.models.signals import post_save
Expand Down
3 changes: 2 additions & 1 deletion mezzanine/accounts/templatetags/accounts_tags.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.utils.datastructures import SortedDict

Expand Down Expand Up @@ -73,7 +74,7 @@ def profile_fields(user):
if field.name not in ("id", user_fieldname) + exclude:
value = getattr(profile, field.name)
fields[field.verbose_name.title()] = value
return fields.items()
return list(fields.items())


@register.filter
Expand Down
1 change: 1 addition & 0 deletions mezzanine/accounts/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.contrib.auth.tokens import default_token_generator
from django.core import mail
Expand Down
1 change: 1 addition & 0 deletions mezzanine/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.conf.urls import patterns, url

Expand Down
1 change: 1 addition & 0 deletions mezzanine/accounts/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.contrib.auth import (authenticate, login as auth_login,
logout as auth_logout)
Expand Down
1 change: 1 addition & 0 deletions mezzanine/bin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""
Provides scripts for building and working with Mezzanine.
"""
from __future__ import unicode_literals
2 changes: 2 additions & 0 deletions mezzanine/bin/mezzanine_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
from __future__ import unicode_literals
from future.builtins import open

from distutils.dir_util import copy_tree
from optparse import OptionParser
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
Provides a blogging app with posts, keywords, categories and comments.
Posts can be listed by month, keyword, category or author.
"""
from __future__ import unicode_literals

from mezzanine import __version__
1 change: 1 addition & 0 deletions mezzanine/blog/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from copy import deepcopy

Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
that are only read during startup shouldn't be editable, since changing
them would require an application reload.
"""
from __future__ import unicode_literals

from django.conf import settings
from django.utils.translation import ugettext_lazy as _
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/feeds.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/forms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django import forms

Expand Down
10 changes: 7 additions & 3 deletions mezzanine/blog/management/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from __future__ import print_function
from __future__ import print_function, unicode_literals
from future.builtins import input, int
from optparse import make_option
from urlparse import urlparse
try:
from urllib.parse import urlparse
except:
from urlparse import urlparse

from django.contrib.redirects.models import Redirect
from django.contrib.sites.models import Site
Expand Down Expand Up @@ -128,7 +132,7 @@ def trunc(self, model, prompt, **fields):
continue
while len(value) > max_length:
encoded_value = value.encode("utf-8")
new_value = raw_input("The value for the field %s.%s exceeds "
new_value = input("The value for the field %s.%s exceeds "
"its maximum length of %s chars: %s\n\nEnter a new value "
"for it, or press return to have it truncated: " %
(model.__name__, field_name, max_length, encoded_value))
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/management/commands/import_blogger.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from datetime import datetime, timedelta
from optparse import make_option
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/management/commands/import_posterous.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from datetime import datetime
import json
Expand Down
10 changes: 8 additions & 2 deletions mezzanine/blog/management/commands/import_rss.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from __future__ import unicode_literals
from future import standard_library

from datetime import timedelta
from optparse import make_option
from time import timezone
from urllib import urlopen
from urlparse import urljoin
try:
from urllib.request import urlopen
from urllib.parse import urljoin
except ImportError:
from urllib import urlopen
from urlparse import urljoin

from django.core.management.base import CommandError

Expand Down
7 changes: 6 additions & 1 deletion mezzanine/blog/management/commands/import_tumblr.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from __future__ import print_function
from __future__ import unicode_literals
from future.builtins import int

from datetime import datetime
from optparse import make_option
from time import sleep
from urllib import urlopen
try:
from urllib.request import urlopen
except ImportError:
from urllib import urlopen

from django.core.management.base import CommandError
from django.utils.html import strip_tags
Expand Down
2 changes: 2 additions & 0 deletions mezzanine/blog/management/commands/import_wordpress.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
from future.builtins import int

from collections import defaultdict
from datetime import datetime, timedelta
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/migrations/0002_auto.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/migrations/0003_categories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import DataMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/migrations/0011_comment_site_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import DataMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import unicode_literals
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
# -*- coding: utf-8 -*-
import datetime
from south.db import db
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
# -*- coding: utf-8 -*-
import datetime
from south.db import db
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
# -*- coding: utf-8 -*-
import datetime
from south.db import db
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
# -*- coding: utf-8 -*-
import datetime
from south.db import db
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
# -*- coding: utf-8 -*-
import datetime
from south.db import db
Expand Down
2 changes: 2 additions & 0 deletions mezzanine/blog/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals
from future.builtins import str
from django.db import models
from django.utils.translation import ugettext_lazy as _

Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/templatetags/blog_tags.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
from datetime import datetime

from django.db.models import Count, Q
Expand Down
7 changes: 6 additions & 1 deletion mezzanine/blog/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from __future__ import unicode_literals
from future import standard_library

from urlparse import urlparse
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse

from django.core.urlresolvers import reverse
from django.utils.unittest import skipUnless
Expand Down
1 change: 1 addition & 0 deletions mezzanine/blog/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.conf.urls import patterns, url

Expand Down
7 changes: 5 additions & 2 deletions mezzanine/blog/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import unicode_literals
from future.builtins import str
from future.builtins import int
from calendar import month_name

from django.http import Http404
Expand Down Expand Up @@ -39,7 +42,7 @@ def blog_post_list(request, tag=None, year=None, month=None, username=None,
category = get_object_or_404(BlogCategory, slug=category)
blog_posts = blog_posts.filter(categories=category)
templates.append(u"blog/blog_post_list_%s.html" %
unicode(category.slug))
str(category.slug))
author = None
if username is not None:
author = get_object_or_404(User, username=username)
Expand Down Expand Up @@ -67,7 +70,7 @@ def blog_post_detail(request, slug, year=None, month=None, day=None,
for_user=request.user).select_related()
blog_post = get_object_or_404(blog_posts, slug=slug)
context = {"blog_post": blog_post, "editable_obj": blog_post}
templates = [u"blog/blog_post_detail_%s.html" % unicode(slug), template]
templates = [u"blog/blog_post_detail_%s.html" % str(slug), template]
return render(request, templates, context)


Expand Down
1 change: 1 addition & 0 deletions mezzanine/boot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
custom fields not being available when custom admin classes are
registered.
"""
from __future__ import unicode_literals

from collections import defaultdict

Expand Down
1 change: 1 addition & 0 deletions mezzanine/boot/lazy_admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals

from django.contrib.admin.sites import AdminSite

Expand Down
Loading