mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: add string_or_unicode to polyglot
To facilitate universal __future__s, we prefer native_string_type to str. Since we cannot compare things as instance(f, (str, unicode_type)) and it gets a bit ridiculous to compare: from polyglot.builtins import native_string_type, unicode_type isinstance(f, (native_string_type, unicode_type)) allow using isinstance(f, string_or_unicode) instead. This matches the existing string_or_bytes comparator.
This commit is contained in:
parent
24cd46cc70
commit
d0a30b1f84
@ -72,6 +72,7 @@ if is_py3:
|
||||
codepoint_to_chr = chr
|
||||
unicode_type = str
|
||||
string_or_bytes = str, bytes
|
||||
string_or_unicode = str
|
||||
long_type = int
|
||||
raw_input = input
|
||||
getcwd = os.getcwd
|
||||
@ -126,6 +127,7 @@ else:
|
||||
codepoint_to_chr = unichr
|
||||
unicode_type = unicode
|
||||
string_or_bytes = unicode, bytes
|
||||
string_or_unicode = str, unicode
|
||||
long_type = long
|
||||
exec_path = execfile
|
||||
raw_input = builtins.raw_input
|
||||
|
Loading…
x
Reference in New Issue
Block a user