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:
Eli Schwartz 2019-08-05 16:09:30 -04:00
parent 24cd46cc70
commit d0a30b1f84
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6

View File

@ -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