[IPython-dev] Python 3 on Windows
Thu Feb 2 10:25:41 CST 2012
On 2 February 2012 16:12, Daniel Griffith <email@example.com>wrote:
> I ran "a = !ls" and tried to "print(a.nlstr)" to see the results, and it
> complained about having bytes instead of strings:
> "TypeError: sequence item 0: expected str instance, bytes found".
> The earlier stage would be in the "!" handler; I haven't looked at that
> code. I assume there are reasons it is putting
> bytes into the SList instead of strings. Maybe it should change instead? I
> don't know. I suppose that would depend
> on whether other code will assume that SList contains only strings and
> whether "!" is returning bytes.
That's the stage I'd look at - the code starts with the getoutput method
The trouble with just calling str is that it doesn't always do what you
might expect, so if we've got bytes, it's better to decode them:
>>> b'abc'.decode() # ...but we need to work out the encoding
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev