Mercurial > python-cmd2
comparison cmd2.py @ 377:70ca35d96c49
decode seems a healthy change
author | cat@eee |
---|---|
date | Mon, 22 Feb 2010 18:09:06 -0500 |
parents | 32b9137577b8 |
children | 0b77ca917fd2 |
comparison
equal
deleted
inserted
replaced
376:32b9137577b8 | 377:70ca35d96c49 |
---|---|
1434 self.old_stdout = sys.stdout | 1434 self.old_stdout = sys.stdout |
1435 self.trap = tempfile.TemporaryFile() | 1435 self.trap = tempfile.TemporaryFile() |
1436 sys.stdout = self.trap | 1436 sys.stdout = self.trap |
1437 def read(self): | 1437 def read(self): |
1438 self.trap.seek(0) | 1438 self.trap.seek(0) |
1439 result = self.trap.read() | 1439 result = self.trap.read().decode() # Py3 sends stdout trap as bytes, not strings |
1440 self.trap.truncate(0) | 1440 self.trap.truncate(0) |
1441 try: | 1441 try: |
1442 return result.strip('\x00') #TODO: understand this | 1442 return result.strip('\x00') #TODO: understand this |
1443 except TypeError: | 1443 except TypeError: |
1444 return result | 1444 return result |