-
-
Notifications
You must be signed in to change notification settings - Fork 541
Ensure native strings in environ #1314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I still need to actually check this on windows -- but I think this fixes it :) |
can confirm this fixes things, however it's insufficient to get tox working on python2.7 on windows: |
@gaborbernat it looks like azure pipelines isn't actually testing python2.7 🙃 |
what 😮
what's this magic 🤔 |
assert env["TOX_ENV_DIR"] == os.path.join(res.cwd, ".tox", tox_id) | ||
# ensure native strings for environ for windows | ||
for k, v in env.items(): | ||
assert type(k) is str, (k, v, type(k)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asottile
A technical question: Why not use isinstance(k, str)
instead of type
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type(...)
is a stronger assertion here than isinstance
-- I'm guarding against subclasses of str
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to the explanation.
In [1]: class foostr(str):
...: pass
...:
...:
In [2]: x = str("bar")
In [3]: y = foostr("bar")
In [4]: type(x)
Out[4]: str
In [5]: type(y)
Out[5]: __main__.foostr
In [6]: isinstance(x, str)
Out[6]: True
In [7]: isinstance(y, str)
Out[7]: True
In [8]: type(x) is str
Out[8]: True
In [9]: type(y) is str
Out[9]: False
No description provided.