Open
Description
This bug is related to the issues with isinstance(..., str)
described here.
The following works in Python 2.7:
from __future__ import unicode_literals
from builtins import str
assert isinstance('some string', str)
However, the following fails (also in Python 2.7):
from __future__ import unicode_literals
from builtins import str
import sys
assert isinstance(sys.argv[0], str)
The reason is that elements of sys.argv
are still instances of the original type str
, not of future.types.newstr.newstr
. This makes working with command line arguments tricky in legacy Py2 code that is being upgraded for Py2/Py3 compatibility using python-future.
For the record, both code snippets above work as expected in Python 3.4.