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.
This commit is contained in:
Sacha 2019-09-24 22:40:48 +02:00 committed by GitHub
parent 62d38e6706
commit 01a549eae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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