Skip to content
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

sys.getfilesystemencoding return value not checked #137

Closed
rjosephwright opened this issue Jul 23, 2010 · 3 comments
Closed

sys.getfilesystemencoding return value not checked #137

rjosephwright opened this issue Jul 23, 2010 · 3 comments
Labels
Milestone

Comments

@rjosephwright
Copy link

On HP-UX, sys.getfilesystemencoding returns None. On line 993 of genutils.py, the result of calling that function is decoded without first checking the return value.

This small patch solved it for me.

-    return ipdir.decode(sys.getfilesystemencoding())
+    fsenc = sys.getfilesystemencoding()
+    if fsenc:
+        return ipdir.decode(fsenc)
+    else:
+        return ipdir
@takluyver
Copy link
Member

Rather than not decoding it, does it make sense to assume a default encoding of some sort, so that we're always returning a path in unicode? Is it possible to include any non-ascii characters in an HP-UX filename? And if so, what do they show up as in Python?

@minrk
Copy link
Member

minrk commented Mar 23, 2011

This is the same issue as #77, but closing that one since this one is more descriptive.

Instead of return ipdir it should be return ipdir.decode() to use default encoding.

Or for fewer lines:
fsenc = sys.getfilesystemencoding() or sys.getdefaultencoding()
return ipdir.decode(fsenc)

@minrk
Copy link
Member

minrk commented Mar 23, 2011

Marking as quickfix, as getfilesystemencoding only appears in IPython.util.path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants