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

closes issue #42, self.buffer decoded implicitly #43

Merged
merged 3 commits into from
Mar 8, 2014

Conversation

jquast
Copy link
Member

@jquast jquast commented Mar 7, 2014

create a unit tests which otherwise failed for python3 only: mock the
return value of set_unique_prompt for a value of False, which causes
ExceptionPxssh to raise.

previously, displaying self.buffer within the exception causes
bytes() to be implicitly decoded to str (unicode type in py3). python2
didn't care. it is implicitly decoded as 'ascii' encoding, without
warning.

Then, use the %r to represent it as b'xyz' in python3. Also, display
what we expected to be more helpful for the user. What is actually
happening here is the 'set PS1=' command is used so that pexpect can
more regularly understand when the prompt is awaiting command input, and
it is set to something more predictable. You'd be suprised what kind of
hackery can happen to prompt values even if PS1 is explicitly set,
especially in today's oh-my-zhs and git-prompt.sh extensions.

create a unit tests which otherwise failed for python3 only: mock the
return value of set_unique_prompt for a value of False, which causes
ExceptionPxssh to raise.

previously, displaying self.buffer within the exception causes
bytes() to be implicitly decoded to str (unicode type in py3). python2
didn't care. it is implicitly decoded as 'ascii' encoding, without
warning.

Then, use the %r to represent it as b'xyz' in python3. Also, display
what we expected to be more helpful for the user. What is actually
happening here is the 'set PS1=' command is used so that pexpect can
more regularly understand when the prompt is awaiting command input, and
it is set to something more predictable. You'd be suprised what kind of
hackery can happen to prompt values even if PS1 is explicitly set,
especially in today's oh-my-zhs and git-prompt.sh extensions.
raise ExceptionPxssh('could not set shell prompt\n'+self.before)
raise ExceptionPxssh('could not set shell prompt '
'(recieved: %r, expected: %r).' % (
self.before, self.PROMPT_SET_SH,))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected self.PROMPT, not self.PROMPT_SET_SH. PROMPT_SET_SH is the command it sends to try to change the prompt.

@takluyver
Copy link
Member

Other than that, this looks good.

completes issue #44; thanks to @takluyver for keen eye.
jquast added a commit that referenced this pull request Mar 8, 2014
…-str

closes issue #42, self.buffer decoded implicitly
@jquast jquast merged commit fcf4ad9 into master Mar 8, 2014
@jquast jquast deleted the issue-42-cannot-implicit-bytes-to-str branch November 23, 2014 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants