]> git.ipfire.org Git - thirdparty/lxc.git/commit
Make lxc-start-ephemeral Python 3.2-compatible
authorColin Watson <cjwatson@ubuntu.com>
Thu, 26 Jan 2017 14:32:08 +0000 (14:32 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 27 Jan 2017 21:20:34 +0000 (16:20 -0500)
commit70cd3b8f65211275363bd2a11254f6d94d389a6f
treeb63d515b25c30d3557874ae0c12d29950cb96108
parente44a5652bcdb3da98764e1bb94399434c0dfbade
Make lxc-start-ephemeral Python 3.2-compatible

On Ubuntu 12.04 LTS with Python 3.2, `lxc-start-ephemeral` breaks as
follows:

    Traceback (most recent call last):
      File "/usr/bin/lxc-start-ephemeral", line 371, in attach_as_user
      File "/usr/lib/python3.2/subprocess.py", line 515, in check_output
      File "/usr/lib/python3.2/subprocess.py", line 732, in __init__
    LookupError: unknown encoding: ANSI_X3.4-1968

This is because `universal_newlines=True` causes `subprocess` to use
`io.TextIOWrapper`, and in versions of Python earlier than 3.3 that
fetched the preferred encoding using `locale.getpreferredencoding()`
rather than `locale.getpreferredencoding(False)`, thereby changing the
locale and causing codecs to be reloaded.  However, `attach_as_user`
runs inside the container and thus can't rely on having access to the
same Python standard library on disk.

The workaround is to decode by hand instead, avoiding the temporary
change of locale.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
src/lxc/lxc-start-ephemeral.in