Fixed python 2 plist unicode support.

This commit is contained in:
Fabio Caccamo 2020-09-10 18:41:34 +02:00
parent c255be26ef
commit bfd2c04a48
1 changed files with 3 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from benedict.serializers.abstract import AbstractSerializer
import plistlib
import six
import unicodedata
class PListSerializer(AbstractSerializer):
@ -17,6 +18,8 @@ class PListSerializer(AbstractSerializer):
def decode(self, s, **kwargs):
if six.PY2:
if isinstance(s, unicode):
s = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore')
return plistlib.readPlistFromString(s)
kwargs.setdefault('fmt', plistlib.FMT_XML)
encoding = kwargs.pop('encoding', 'utf-8')