1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-26 16:41:29 +02:00

Removed polyglots unicode_type usage

This commit is contained in:
2020-04-20 19:25:28 +02:00
parent ef7e2b10be
commit 128705f258
130 changed files with 657 additions and 716 deletions
+2 -3
View File
@@ -1,5 +1,4 @@
import re, codecs
from ebook_converter.polyglot.builtins import unicode_type
__license__ = 'GPL v3'
@@ -131,7 +130,7 @@ def force_encoding(raw, verbose, assume_utf8=False):
def detect_xml_encoding(raw, verbose=False, assume_utf8=False):
if not raw or isinstance(raw, unicode_type):
if not raw or isinstance(raw, str):
return raw, None
for x in ('utf8', 'utf-16-le', 'utf-16-be'):
bom = getattr(codecs, 'BOM_'+x.upper().replace('-16', '16').replace(
@@ -175,7 +174,7 @@ def xml_to_unicode(raw, verbose=False, strip_encoding_pats=False,
return '', None
raw, encoding = detect_xml_encoding(raw, verbose=verbose,
assume_utf8=assume_utf8)
if not isinstance(raw, unicode_type):
if not isinstance(raw, str):
raw = raw.decode(encoding, 'replace')
if strip_encoding_pats: