mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-03-05 18:53:31 +01:00
Fix printing of tracebacks broken when third party plugins with non-UTF-8 source code present
This commit is contained in:
parent
37fee2b5b2
commit
6ba70b06aa
1 changed files with 5 additions and 1 deletions
|
|
@ -164,7 +164,11 @@ def get_source_as_bytes(self, fullname=None):
|
|||
return src
|
||||
|
||||
def get_source(self, fullname=None):
|
||||
return self.get_source_as_bytes(fullname).decode('utf-8-sig').replace('\r\n', '\n')
|
||||
raw = self.get_source_as_bytes(fullname)
|
||||
try:
|
||||
return raw.decode('utf-8-sig', 'replace').replace('\r\n', '\n')
|
||||
except Exception:
|
||||
return ''
|
||||
|
||||
def get_filename(self, fullname):
|
||||
return self.filename
|
||||
|
|
|
|||
Loading…
Reference in a new issue