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

UnicodeDecodeError on directory with unicode chars in prompt #1961

Closed
kernc opened this issue Jun 14, 2012 · 2 comments · Fixed by #1962
Closed

UnicodeDecodeError on directory with unicode chars in prompt #1961

kernc opened this issue Jun 14, 2012 · 2 comments · Fixed by #1962
Milestone

Comments

@kernc
Copy link

kernc commented Jun 14, 2012

Version: ipython 0.12

With prompt set to:

c.PromptManager.in_template = u'\r \w \$ '  # \r needed so prompt doesn't hang in the middle in some cases, 
                                            # \w prints current dir, 
                                            # u"←string modifier" doesn't really help at all

when I try to cd into a directory with unicode character in its name, a UnicodeDecodeError gets thrown.

How to reproduce:

  1. set above prompt
  2. /home/user $ mkdir č
  3. /home/user $ cd č

Expected:
/home/user/č

Instead:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 9: ordinal not in range(128)

Remarks:
With no \w in prompt, it works as expected.

@takluyver
Copy link
Member

I think we just need to use os.getcwdu instead of os.getcwd in IPython.core.prompts.

@kernc
Copy link
Author

kernc commented Jun 14, 2012

yup, I'm reading through some old bugs now (got more to report :P), and it seems all os.getwd() calls should instead be os.getcwdu() (perhaps always and in all international apps).

@minrk minrk closed this as completed in 4eb5db2 Jun 15, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Support unicode prompts

fixes potential issues when cwd/USER/HOME might have been unicode.

closes ipython#1961
closes ipython#1963
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants