calibre/src/polyglot/plistlib.py
Kovid Goyal 5b2baa7233
Fix for plistlib dropping Data in python 3.9
Fixes #1184 (plistlib.Data is going to be dropped in python 3.9)
2020-07-02 08:42:18 +05:30

26 lines
633 B
Python

#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
from polyglot.builtins import is_py3
if is_py3:
from plistlib import loads, dumps # noqa
def unwrap_bytes(x):
return x
def wrap_bytes(x):
return x
else:
from plistlib import readPlistFromString as loads, writePlistToString as dumps, Data # noqa
def unwrap_bytes(x):
if isinstance(x, Data):
x = x.data
return x
def wrap_bytes(x):
return Data(x)