From 01a549eae642c30febd2809d72be6beb21c81cef Mon Sep 17 00:00:00 2001 From: Sacha Date: Tue, 24 Sep 2019 22:40:48 +0200 Subject: [PATCH] Avoid error on python3 about str and bytes When I launch the calibre application build for python3 I get two errors about expecting bytes not str and the other way around. in src/calibre/devices/mtp/driver.py and src/calibre/devices/mtp/unix/driver.py I found that theses edits remove the error. --- src/calibre/devices/mtp/driver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/devices/mtp/driver.py b/src/calibre/devices/mtp/driver.py index 6b5fd66745..20c6231aa3 100644 --- a/src/calibre/devices/mtp/driver.py +++ b/src/calibre/devices/mtp/driver.py @@ -176,6 +176,7 @@ class MTP_DEVICE(BASE): dinfo['date_last_connected'] = isoformat(now()) dinfo['mtp_prefix'] = storage.storage_prefix raw = json.dumps(dinfo, default=to_json) + raw = bytes(raw,encoding='utf8') if isinstance(raw, str) else raw self.put_calibre_file(storage, 'driveinfo', BytesIO(raw), len(raw)) self.driveinfo[location_code] = dinfo