From 27851b8eb58d81d39b5051cc9e7e8165327bb680 Mon Sep 17 00:00:00 2001 From: Tomas Date: Tue, 24 Sep 2019 13:16:34 +0200 Subject: [PATCH] Change python3 compatibility --- .travis.yml | 14 ++++++++++++++ multiselectfield/db/fields.py | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0b33c0e..a02855a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,20 @@ matrix: env: DJANGO_VERSION='Django>=1.9,<1.10' - python: "3.6" env: DJANGO_VERSION='Django>=1.10,<1.11' + - python: "3.7" + env: DJANGO_VERSION='Django>=1.4,<1.5' + - python: "3.7" + env: DJANGO_VERSION='Django>=1.5,<1.6' + - python: "3.7" + env: DJANGO_VERSION='Django>=1.6,<1.7' + - python: "3.7" + env: DJANGO_VERSION='Django>=1.7,<1.8' + - python: "3.7" + env: DJANGO_VERSION='Django>=1.8,<1.9' + - python: "3.7" + env: DJANGO_VERSION='Django>=1.9,<1.10' + - python: "3.7" + env: DJANGO_VERSION='Django>=1.10,<1.11' install: - pip install -q $DJANGO_VERSION diff --git a/multiselectfield/db/fields.py b/multiselectfield/db/fields.py index 85bc5eb..cb5e68f 100644 --- a/multiselectfield/db/fields.py +++ b/multiselectfield/db/fields.py @@ -20,7 +20,6 @@ from django import VERSION from django.db import models from django.utils.text import capfirst -from django.utils.encoding import python_2_unicode_compatible from django.core import exceptions from ..forms.fields import MultiSelectFormField, MinChoicesValidator, MaxChoicesValidator @@ -47,7 +46,6 @@ def add_metaclass(metaclass): return wrapper -@python_2_unicode_compatible class MSFList(list): def __init__(self, choices, *args, **kwargs): @@ -58,6 +56,10 @@ class MSFList(list): msg_list = [msgl.choices.get(int(i)) if i.isdigit() else msgl.choices.get(i) for i in msgl] return u', '.join([string_type(s) for s in msg_list]) + if sys.version_info < (3,): + def __unicode__(self, msgl): + return self.__str__(msgl) + class MultiSelectField(models.CharField): """ Choice values can not contain commas. """