Fix #1693496 [UnicodeDecodeError - cant' change title of a PDF file](https://bugs.launchpad.net/calibre/+bug/1693496)

This commit is contained in:
Kovid Goyal 2017-05-25 20:05:12 +05:30
parent 4e46901cb3
commit 4a0db45362
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -12,7 +12,7 @@ from itertools import groupby
from PyQt5.Qt import (QAbstractTableModel, Qt, pyqtSignal, QIcon, QImage, from PyQt5.Qt import (QAbstractTableModel, Qt, pyqtSignal, QIcon, QImage,
QModelIndex, QDateTime, QColor, QPixmap, QPainter, QApplication) QModelIndex, QDateTime, QColor, QPixmap, QPainter, QApplication)
from calibre import fit_image from calibre import fit_image, force_unicode
from calibre.gui2 import error_dialog from calibre.gui2 import error_dialog
from calibre.utils.search_query_parser import ParseException from calibre.utils.search_query_parser import ParseException
from calibre.ebooks.metadata import fmt_sidx, authors_to_string, string_to_authors from calibre.ebooks.metadata import fmt_sidx, authors_to_string, string_to_authors
@ -1094,11 +1094,11 @@ class BooksModel(QAbstractTableModel): # {{{
import traceback import traceback
if getattr(err, 'errno', None) == errno.EACCES: # Permission denied if getattr(err, 'errno', None) == errno.EACCES: # Permission denied
fname = getattr(err, 'filename', None) fname = getattr(err, 'filename', None)
p = 'Locked file: %s\n\n'%fname if fname else '' p = 'Locked file: %s\n\n'%force_unicode(fname if fname else '')
error_dialog(get_gui(), _('Permission denied'), error_dialog(get_gui(), _('Permission denied'),
_('Could not change the on disk location of this' _('Could not change the on disk location of this'
' book. Is it open in another program?'), ' book. Is it open in another program?'),
det_msg=p+traceback.format_exc(), show=True) det_msg=p+force_unicode(traceback.format_exc()), show=True)
return False return False
error_dialog(get_gui(), _('Failed to set data'), error_dialog(get_gui(), _('Failed to set data'),
_('Could not set data, click Show Details to see why.'), _('Could not set data, click Show Details to see why.'),