diff --git a/src/calibre/library/catalogs/bibtex.py b/src/calibre/library/catalogs/bibtex.py index d21d9a6fa7..445e2e24c0 100644 --- a/src/calibre/library/catalogs/bibtex.py +++ b/src/calibre/library/catalogs/bibtex.py @@ -14,7 +14,7 @@ from calibre.library.catalogs import FIELDS, TEMPLATE_ALLOWED_FIELDS from calibre.customize.conversion import DummyReporter from calibre.constants import preferred_encoding from calibre.ebooks.metadata import format_isbn -from polyglot.builtins import string_or_bytes, unicode_type +from polyglot.builtins import string_or_bytes class BIBTEX(CatalogPlugin): @@ -350,7 +350,7 @@ class BIBTEX(CatalogPlugin): bibtexc.ascii_bibtex = True # Check citation choice and go to default in case of bad CLI - if isinstance(opts.impcit, (str, unicode_type)) : + if isinstance(opts.impcit, string_or_bytes) : if opts.impcit == 'False' : citation_bibtex= False elif opts.impcit == 'True' : @@ -362,7 +362,7 @@ class BIBTEX(CatalogPlugin): citation_bibtex= opts.impcit # Check add file entry and go to default in case of bad CLI - if isinstance(opts.addfiles, (StringType, UnicodeType)) : + if isinstance(opts.addfiles, string_or_bytes) : if opts.addfiles == 'False' : addfiles_bibtex = False elif opts.addfiles == 'True' : diff --git a/src/calibre/srv/http_response.py b/src/calibre/srv/http_response.py index 8313d18e32..c1b5547bf5 100644 --- a/src/calibre/srv/http_response.py +++ b/src/calibre/srv/http_response.py @@ -30,6 +30,8 @@ from polyglot import http_client, reprlib Range = namedtuple('Range', 'start stop size') MULTIPART_SEPARATOR = uuid.uuid4().hex +if isinstance(MULTIPART_SEPARATOR, bytes): + MULTIPART_SEPARATOR = MULTIPART_SEPARATOR.decode('ascii') COMPRESSIBLE_TYPES = {'application/json', 'application/javascript', 'application/xml', 'application/oebps-package+xml'} if is_py3: import zlib @@ -450,7 +452,10 @@ class HTTPConnection(HTTPRequest): def send_range_not_satisfiable(self, content_length): buf = [ - '%s %d %s' % (self.response_protocol, http_client.REQUESTED_RANGE_NOT_SATISFIABLE, http_client.responses[http_client.REQUESTED_RANGE_NOT_SATISFIABLE]), + '%s %d %s' % ( + self.response_protocol, + http_client.REQUESTED_RANGE_NOT_SATISFIABLE, + http_client.responses[http_client.REQUESTED_RANGE_NOT_SATISFIABLE]), "Date: " + http_date(), "Content-Range: bytes */%d" % content_length, ] diff --git a/src/calibre/utils/unrar.py b/src/calibre/utils/unrar.py index fc6a767843..a11ad5fc9e 100644 --- a/src/calibre/utils/unrar.py +++ b/src/calibre/utils/unrar.py @@ -127,8 +127,9 @@ def test_basic(): def do_test(stream): c = comment(stream) - if c != 'some comment\n': - raise ValueError('Comment not read: %r != %r' % (c, b'some comment\n')) + expected = 'some comment\n' + if c != expected: + raise ValueError('Comment not read: %r != %r' % (c, expected)) if set(names(stream)) != { '1/sub-one', 'one.txt', '2/sub-two.txt', '诶比屁.txt', 'Füße.txt', 'uncompressed', 'max-compressed'}: