From e05bf3e56fa049d3b4ecaddc2ab5cd4346b6e4a5 Mon Sep 17 00:00:00 2001 From: Jens Kleineheismann Date: Thu, 28 Mar 2019 16:54:58 +0100 Subject: [PATCH] FIX: Get rid of basestring (not python3 compatible). --- dav_auth/tests/test_apps.py | 5 +++-- dav_base/tests/test_apps.py | 7 ++++--- dav_events/converters.py | 5 +++-- dav_events/forms/events.py | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dav_auth/tests/test_apps.py b/dav_auth/tests/test_apps.py index 533c63a..16b5c63 100644 --- a/dav_auth/tests/test_apps.py +++ b/dav_auth/tests/test_apps.py @@ -1,4 +1,5 @@ from django.apps import apps +from six import string_types from dav_base.tests.generic import AppSetting, AppsTestCase @@ -7,6 +8,6 @@ class TestCase(AppsTestCase): app_config = apps.get_app_config('dav_auth') settings = ( - AppSetting('login_redirect_url', basestring), - AppSetting('logout_redirect_url', basestring), + AppSetting('login_redirect_url', string_types), + AppSetting('logout_redirect_url', string_types), ) diff --git a/dav_base/tests/test_apps.py b/dav_base/tests/test_apps.py index 589b3a2..a210d65 100644 --- a/dav_base/tests/test_apps.py +++ b/dav_base/tests/test_apps.py @@ -1,4 +1,5 @@ from django.apps import apps +from six import string_types from .generic import AppSetting, AppsTestCase @@ -7,7 +8,7 @@ class TestCase(AppsTestCase): app_config = apps.get_app_config('dav_base') settings = ( - AppSetting('email_sender', basestring), - AppSetting('email_base_url', basestring), - AppSetting('email_subject_prefix', basestring), + AppSetting('email_sender', string_types), + AppSetting('email_base_url', string_types), + AppSetting('email_subject_prefix', string_types), ) diff --git a/dav_events/converters.py b/dav_events/converters.py index 682188f..c4e3f85 100644 --- a/dav_events/converters.py +++ b/dav_events/converters.py @@ -1,6 +1,7 @@ import datetime import logging import re +from six import string_types logger = logging.getLogger(__name__) @@ -53,7 +54,7 @@ class Iso8601Serializer(object): @classmethod def deserialize(cls, value, ignore_unsupported_input=False): prefix = '{marker}{sep}'.format(marker=cls.marker, sep=cls.separator) - if isinstance(value, basestring) and value.startswith(prefix): + if isinstance(value, string_types) and value.startswith(prefix): haystack = value[len(prefix):] m = cls._re.match(haystack) if m is not None: @@ -68,6 +69,6 @@ class Iso8601Serializer(object): elif not ignore_unsupported_input: raise ValueError('Format not recognized \'{str}\''.format(str=haystack)) elif not ignore_unsupported_input: - raise ValueError('Expected basestring,' + raise ValueError('Expected string type,' ' not {}'.format(value.__class__.__name__)) return value diff --git a/dav_events/forms/events.py b/dav_events/forms/events.py index 2215d24..56c14e0 100644 --- a/dav_events/forms/events.py +++ b/dav_events/forms/events.py @@ -9,6 +9,7 @@ from django.apps import apps from django.utils.translation import get_language, ugettext, ugettext_lazy as _ from django_countries.fields import Country, LazyTypedChoiceField from datetimewidget.widgets import DateWidget, TimeWidget, DateTimeWidget +from six import string_types from .. import choices from .. import config @@ -162,7 +163,7 @@ class EventCreateForm(ModelMixin, ChainedForm): kwargs = self._session_data.copy() if 'deadline' in kwargs: buf = kwargs['deadline'] - if isinstance(buf, basestring): + if isinstance(buf, string_types): deadline_choice = buf.lower() deadline_field = 'deadline_{}'.format(deadline_choice) if deadline_field in kwargs: