You get this instead:
SyntaxError: (unicode error) 'rawunicodeescape' codec can't decode bytes in position 2-3: truncated \uXXXX
It does work fine in python3 with native unicode str()
So there is no need to convert everything to lists before and after.
Also, all_formats is immediately converted to a set, and kept that way,
so it does not need to always be accessed as set(all_formats).
QComboBox.addItems() accepts any iterable, and there's no reason to use
map plus a list comprehension to operate on the same data.
- input_formats will currently be lowercase, output_formats is uppercase.
Without documenting this inconsistent internal API, don't rely on it.
- While all builtin output plugins should have unicode_literals compatible
file_type attributes, at least this assumption might break for custom
plugins, so continue mapping to unicode_type.
Well, at least we can reduce the number of allocated lists.
b'1' can be mapped into an int, but 'b"1"' cannot. Also rename one
instance -- the QMimeData class requires using the data() method to
retrieve content, and QByteArray uses data() to retrieve the raw bytes,
but once we get to data.data().data() it's a bit ridiculous. So make the
first one be called md, as is used in other mime handling code too.
Even though we adapted to python3 by using a tuple to ensure the
function is actually applied, this still uses a surprising language
feature then allocate a tuple that is immediately tossed away.
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.