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

Fixed TypeError using readline with spawnu #67

Closed
wants to merge 5 commits into from

Conversation

auntieNeo
Copy link

There seems to be a bug in the spawn.readline() function that makes it impossible to use with spawnu objects (i.e. when using strings rather than bytes). I wrote a small patch that fixes this. I tested with Python 3.2 on cygwin. I also included a small test that can reproduce this bug.

strings.
"""
child = pexpect.spawnu(ECHO, [ "foobar"])
foobar = child.readline()
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this a proper test case - i.e. it shouldn't run on import. I'd probably put it in test_unicode as well, rather than making a new file for it.

@auntieNeo
Copy link
Author

I implemented the changes you suggested. I also added a test for spawn() in addition to spawnu(). I tested it on both python2.7 and python3.4, but let me know if there are any errors in the string types. I'll admit they continue to confuse me in python.

@jquast
Copy link
Member

jquast commented Jun 9, 2014

Thank you! Added to doc/history.rst and split spawn() tests beside its neighbors in test_misc.py.

merge --squashed as commit 8aea7dd

@jquast jquast closed this Jun 9, 2014
jquast referenced this pull request Jun 9, 2014
Submitted by @auntieNeo, fixes exception, "TypeError:
got <type 'str'> ('\r\n') as pattern" in spawnu.readline().

Bytes b'\r\n' was concatenated to u'unicode', causing an
exception to be thrown when using readline().
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

3 participants