Skip to content

Instantly share code, notes, and snippets.

@saulshanabrook
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saulshanabrook/80da9c4a9d162bed2529 to your computer and use it in GitHub Desktop.
Save saulshanabrook/80da9c4a9d162bed2529 to your computer and use it in GitHub Desktop.
docker python unicode read bug
$ docker build .
docker build .
Sending build context to Docker daemon 35.84 kB
Sending build context to Docker daemon
Step 0 : FROM python:3
 ---> cb8d462c9cc4
Step 1 : ADD . /code/
 ---> 12f5f950f84f
Removing intermediate container fb9bedc61d93
Step 2 : WORKDIR /code/
 ---> Running in 4b665cad845e
 ---> 0177a4167de2
Removing intermediate container 4b665cad845e
Step 3 : RUN python open_file.py
 ---> Running in 0443253b5b68
Traceback (most recent call last):
  File "open_file.py", line 1, in <module>
    open('file with unicode').read()
  File "/usr/local/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 23: ordinal not in range(128)
2014/07/29 12:44:28 The command [/bin/sh -c python open_file.py] returned a non-zero code: 1
FROM python:3
ADD . /code/
WORKDIR /code/
# ENV LANG C.UTF-8 if this is uncluded, no error
RUN python open_file.py
some unicode character ❣
open('file with unicode').read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment