python3: replace unicode type to six.text_type (#40012)
This commit is contained in:
parent
517ef1d334
commit
9ef19058c8
|
@ -16,6 +16,7 @@
|
|||
|
||||
from django.core.validators import RegexValidator
|
||||
from django.db import models
|
||||
from django.utils import six
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
|
@ -68,7 +69,7 @@ class AttributeDefinition(models.Model):
|
|||
|
||||
def as_dict(self):
|
||||
as_dict = dict([(x, y) for (x, y) in self.__dict__.items()
|
||||
if type(y) in (str, unicode, bool)])
|
||||
if type(y) in (str, six.text_type, bool)])
|
||||
return as_dict
|
||||
|
||||
def get_real_kind_display(self):
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from django.utils import six
|
||||
|
||||
def byteify(input):
|
||||
if isinstance(input, dict):
|
||||
return {byteify(key): byteify(value)
|
||||
for key, value in input.iteritems()}
|
||||
elif isinstance(input, list):
|
||||
return [byteify(element) for element in input]
|
||||
elif isinstance(input, unicode):
|
||||
elif isinstance(input, six.text_type):
|
||||
return input.encode('utf-8')
|
||||
else:
|
||||
return input
|
||||
|
|
Loading…
Reference in New Issue