-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
ipdir unicode #393
ipdir unicode #393
Conversation
Thanks, I think the check should actually be done on most of the functions though, not just the one reporting the bug. Probably every time we call decode, it should be inside an |
As far as I know, all the things we're getting from environment variables and |
Do you want to go through, and just make sure that everywhere that we call '.decode()' in utils.path, we never do it on a unicode object? These aren't called frequently, so the possibility of wasting cycles double checking is not as bad as the possibility of calling decode on a unicode object, which will always fail if the unicode object actually contains any unicode. Maybe just add: def _maybe_decode(s, enc=sys.defaultencoding()): if isinstance(s, unicode): return s else: return s.decode(enc) And replace all calls to |
My belief from reading the code is that all those functions in utils.path On 23 April 2011 22:35, minrk <
|
OK, I've added the helper function, so all those functions should work whether they end up trying to use bytes or unicode. |
Looks great. I'll go ahead and merge. |
This builds on Min's pull request #362. Bug #392 revealed that, in some circumstances, ipdir can already be unicode before we try to decode it. That can result in a confusing error as it attempts to re-encode it and decode again.
I've simply added a check whether ipdir is unicode or bytes before doing the conversion. Michał says that this fixes the issue (#392) for him.