mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A couple of fixes for the last py3 compat PR
This commit is contained in:
parent
c897bc1a5d
commit
28145e76b0
@ -12,8 +12,8 @@ from threading import RLock
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre import prints, as_unicode
|
from calibre import prints, as_unicode, force_unicode
|
||||||
from calibre.constants import plugins, islinux, isosx
|
from calibre.constants import plugins, islinux, isosx, ispy3
|
||||||
from calibre.ptempfile import SpooledTemporaryFile
|
from calibre.ptempfile import SpooledTemporaryFile
|
||||||
from calibre.devices.errors import OpenFailed, DeviceError, BlacklistedDevice, OpenActionNeeded
|
from calibre.devices.errors import OpenFailed, DeviceError, BlacklistedDevice, OpenActionNeeded
|
||||||
from calibre.devices.mtp.base import MTPDeviceBase, synchronous, debug
|
from calibre.devices.mtp.base import MTPDeviceBase, synchronous, debug
|
||||||
@ -166,8 +166,12 @@ class MTP_DEVICE(MTPDeviceBase):
|
|||||||
@synchronous
|
@synchronous
|
||||||
def create_device(self, connected_device):
|
def create_device(self, connected_device):
|
||||||
d = connected_device
|
d = connected_device
|
||||||
|
man, prod = d.manufacturer, d.prod
|
||||||
|
if ispy3:
|
||||||
|
man = force_unicode(man, 'utf-8') if isinstance(man, bytes) else man
|
||||||
|
prod = force_unicode(prod, 'utf-8') if isinstance(prod, bytes) else prod
|
||||||
return self.libmtp.Device(d.busnum, d.devnum, d.vendor_id,
|
return self.libmtp.Device(d.busnum, d.devnum, d.vendor_id,
|
||||||
d.product_id, d.manufacturer, d.product, d.serial)
|
d.product_id, man, prod, d.serial)
|
||||||
|
|
||||||
@synchronous
|
@synchronous
|
||||||
def eject(self):
|
def eject(self):
|
||||||
|
@ -83,7 +83,7 @@ static PyObject *
|
|||||||
PDFDoc_save(PDFDoc *self, PyObject *args) {
|
PDFDoc_save(PDFDoc *self, PyObject *args) {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
if (PyArg_ParseTuple(args, BYTES_FMT, &buffer)) {
|
if (PyArg_ParseTuple(args, "s", &buffer)) {
|
||||||
try {
|
try {
|
||||||
self->doc->Write(buffer);
|
self->doc->Write(buffer);
|
||||||
} catch(const PdfError & err) {
|
} catch(const PdfError & err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user