Fix various py3 compatibility (refs GH-625)
This commit is contained in:
parent
6a7b821a5d
commit
cd8c6dee64
|
@ -142,7 +142,7 @@ def get_client(client=None, reset=False):
|
|||
options.setdefault('release', ga('RELEASE'))
|
||||
|
||||
transport = ga('TRANSPORT') or options.get('transport')
|
||||
if isinstance(transport, basestring):
|
||||
if isinstance(transport, six.string_types):
|
||||
transport = import_string(transport)
|
||||
options['transport'] = transport
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ from raven.conf import setup_logging
|
|||
from raven.base import Client
|
||||
from raven.middleware import Sentry as SentryMiddleware
|
||||
from raven.handlers.logging import SentryHandler
|
||||
from raven.utils import six
|
||||
from raven.utils.compat import _urlparse
|
||||
from raven.utils.imports import import_string
|
||||
from raven.utils.wsgi import get_headers, get_environ
|
||||
|
@ -36,7 +37,7 @@ def make_client(client_cls, app, dsn=None):
|
|||
# TODO(dcramer): django and Flask share very similar concepts here, and
|
||||
# should be refactored
|
||||
transport = app.config.get('SENTRY_TRANSPORT')
|
||||
if isinstance(transport, basestring):
|
||||
if isinstance(transport, six.string_types):
|
||||
transport = import_string(transport)
|
||||
|
||||
return client_cls(
|
||||
|
|
|
@ -2,8 +2,6 @@ from __future__ import absolute_import
|
|||
|
||||
|
||||
def import_string(key):
|
||||
key = str(key)
|
||||
|
||||
if '.' not in key:
|
||||
return __import__(key)
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import with_statement
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
import django
|
||||
|
@ -716,7 +715,7 @@ class PromiseSerializerTestCase(TestCase):
|
|||
assert result == expected
|
||||
|
||||
def test_real_gettext_lazy(self):
|
||||
d = {'lazy_translation': gettext_lazy('testing')}
|
||||
d = {u'lazy_translation': gettext_lazy(u'testing')}
|
||||
key = "'lazy_translation'" if six.PY3 else "u'lazy_translation'"
|
||||
value = "'testing'" if six.PY3 else "u'testing'"
|
||||
assert transform(d) == {key: value}
|
||||
|
|
Loading…
Reference in New Issue