Skip to content

Print the return from pexpect.run, I see nothing (bpython version 0.9.5.2 on top of Python 2.6.5) #119

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

Closed
ikanobori opened this issue Jul 4, 2014 · 6 comments
Labels

Comments

@ikanobori
Copy link
Contributor

#!pycon

>>> import pexpect
>>> pexpect.run('ls')
'bitbucket  client  exercise  github\r\n'
>>> s=pexpect.run('ls')
>>> print s


>>> s
'bitbucket  client  exercise  github\r\n'
>>> 

@ikanobori
Copy link
Contributor Author

That does not really resolve the handling of a plain "\r" (cursor should go to the beginning of line and overwrite the previous line with new content). Also, there is urwid and gtk which need a fix.


Original Comment By: Andreas Stührk

@ikanobori
Copy link
Contributor Author

What about a workaround trivial like this one?
{{{

--- a/bpython/cli.py Sat Jul 03 14:04:21 2010 +0200
+++ b/bpython/cli.py Sun Jul 04 09:51:11 2010 +0200
@@ -479,6 +479,8 @@
s = s.replace('\x01', '')
# Replace NUL bytes, as addstr raises an exception otherwise
s = s.replace('\x00', '')

  •    # Replace \r\n bytes, as addstr remove the current line otherwise
    
  •    s = s.replace('\x0D\x0A', '\x0A')
    
     self.scr.addstr(s, a)
    

}}}


Original Comment By: Michele Orrù

@ikanobori
Copy link
Contributor Author

This is the behaviour of curses' addstr(), we should probably work around that (in a general way, all our backends behave differently right now).


Original Comment By: Andreas Stührk

@ikanobori
Copy link
Contributor Author

The real issue here seems to be that bpython does not like printing lines with a carriage return in it.

E.g.
{{{

print "spam\r\nspam"

spam

}}}

vs.
{{{

print "spam\nspam"
spam
spam

}}}


Original Comment By: Andreas Stührk

@ikanobori
Copy link
Contributor Author

oops, reported as anonymous, but 'tis really me!


Original Comment By:

@sebastinas
Copy link
Contributor

This is no longer an issue in bpython-curses.

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

No branches or pull requests

2 participants