diff --git a/src/calibre/ebooks/pdb/palmdoc/writer.py b/src/calibre/ebooks/pdb/palmdoc/writer.py index 6a7d54a586..702b176af9 100644 --- a/src/calibre/ebooks/pdb/palmdoc/writer.py +++ b/src/calibre/ebooks/pdb/palmdoc/writer.py @@ -34,7 +34,7 @@ class Writer(FormatWriter): self.log.info('Compessing data...') for i in range(0, len(txt_records)): self.log.debug('\tCompressing record %i' % i) - txt_records[i] = compress_doc(txt_records[i].encode('utf-8')) + txt_records[i] = compress_doc(txt_records[i].encode('cp1252', 'replace')) section_lengths.append(len(txt_records[i])) out_stream.seek(0) diff --git a/src/calibre/ebooks/pdb/ztxt/writer.py b/src/calibre/ebooks/pdb/ztxt/writer.py index 5d8aa97a69..608bcc033a 100644 --- a/src/calibre/ebooks/pdb/ztxt/writer.py +++ b/src/calibre/ebooks/pdb/ztxt/writer.py @@ -33,7 +33,7 @@ class Writer(FormatWriter): self.log.info('Compressing data...') for i in range(0, len(txt_records)): self.log.debug('\tCompressing record %i' % i) - txt_records[i] = compressor.compress(txt_records[i].encode('utf-8')) + txt_records[i] = compressor.compress(txt_records[i].encode('cp1252', 'replace')) txt_records[i] = txt_records[i] + compressor.flush(zlib.Z_FULL_FLUSH) section_lengths.append(len(txt_records[i])) crc32 = zlib.crc32(txt_records[i], crc32) & 0xffffffff diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index a5651397d0..1cfbae905a 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -55,7 +55,7 @@ class Worker(Thread): try: Thread.run(self) self.exception = self.traceback = None - except Exception, err: + except Exception as err: self.exception = err self.traceback = traceback.format_exc() @@ -543,8 +543,9 @@ class EbookViewer(MainWindow, Ui_EbookViewer): if isinstance(worker.exception, DRMError): error_dialog(self, _('DRM Error'), _('
This book is protected by DRM')%'http://wiki.mobileread.com/wiki/DRM').exec_() else: + r = getattr(worker.exception, 'reason', worker.exception) error_dialog(self, _('Could not open ebook'), - unicode(worker.exception), det_msg=worker.traceback, show=True) + unicode(r), det_msg=worker.traceback, show=True) self.close_progress_indicator() else: self.metadata.show_opf(self.iterator.opf)