Initial fixes for python 3 support

This commit is contained in:
Michael van Tellingen 2013-01-30 19:41:40 +01:00
parent c5c0feff9f
commit 2877b66982
4 changed files with 9 additions and 7 deletions

View file

@ -1,8 +1,8 @@
language: python
python:
- "2.5"
- "2.6"
- "2.7"
- "3.3"
before_install:
- export PIP_USE_MIRRORS=true
- export PIP_INDEX_URL=https://simple.crate.io/
@ -14,3 +14,4 @@ script:
env:
- DJANGO=1.3.3
- DJANGO=1.4.1
- DJANGO=1.5rc1

View file

@ -1,3 +1,4 @@
import six
from django.conf import global_settings
from django.core.exceptions import ImproperlyConfigured
@ -15,7 +16,7 @@ install_failure = ("django-configurations settings importer wasn't "
class SettingsBase(type):
def __new__(cls, name, bases, attrs):
if bases != (object,):
if bases != (object,) and bases[0].__name__ != 'NewBase':
# if this is actually a subclass in a settings module
# we better check if the importer was correctly installed
from . import importer
@ -33,7 +34,7 @@ class SettingsBase(type):
return "<Settings '%s.%s'>" % (self.__module__, self.__name__)
class Settings(object):
class Settings(six.with_metaclass(SettingsBase)):
"""
The base configuration class to inherit from.
@ -57,4 +58,4 @@ class Settings(object):
to the name of the class.
"""
__metaclass__ = SettingsBase
pass

View file

@ -78,7 +78,7 @@ def install():
'DJANGO_CONFIGURATION environment variable will '
'be used.'),)
sys.meta_path.append(SettingsImporter())
sys.meta_path.insert(0, SettingsImporter())
installed = True
# now patch the active runserver command to show a nicer output
@ -145,7 +145,7 @@ class SettingsLoader(object):
(self.name, mod.__package__))
try:
obj = cls()
except Exception, err:
except Exception as err:
raise ImproperlyConfigured("Couldn't load settings '%s.%s': %s" %
(mod.__name__, self.name, err))
for name, value in uppercase_attributes(obj).items():

View file

@ -6,7 +6,7 @@ from setuptools import setup
def read(*parts):
file_path = path.join(path.dirname(__file__), *parts)
return codecs.open(file_path).read()
return codecs.open(file_path, encoding='utf-8').read()
def find_version(*parts):