Help me with a bytes decoding problem in python 3

Chris Angelico rosuav at gmail.com
Thu Jun 21 18:36:25 EDT 2012


On Fri, Jun 22, 2012 at 8:30 AM, J <dreadpiratejeff at gmail.com> wrote:
> I'm wondering now... the way it works is that the program is run from
> a user terminal/console.  however, on the other side (after the reboot
> is done) it runs via an autostart script after the user is logged in,
> and thus runs outside of the terminal.  So I wonder if THAT could be
> the root cause of this headache...  maybe there's something about the
> program being run outside of a user shell and generating those
> characters that causes the hang.

It may be a difference in the default encoding of STDIN/STDOUT. When
you're running in a terminal, they're probably being set to UTF-8, so
Python's reading and writing will be in Unicode; possibly it's set to
ASCII

import sys
print(sys.stdin.encoding)

There are many potential differences between TTY access and whatever
happens on startup. How is your script being invoked? Is it through
Upstart? I know you can arrange where stdio go in Upstart scripts.

ChrisA



More information about the Python-list mailing list