From 3a5194302e76e37fa98413558e6ee4e2699635a9 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 23 Oct 2026 15:51:44 -0700 Subject: [PATCH] Set LANG on all Linux variants again, including 3.13+ Restore `ENV LANG C.UTF-8` on 3.13 and later, undoing the 3.13+ part of 0d539116. Without it, two groups of users break: embedded interpreters (uWSGI, mod_wsgi) before 3.15, which fall back to ASCII filesystem and stdio encodings because they don't get the locale coercion and UTF-8 mode that the `python` CLI does, and alpine on every version through 3.16-rc, where musl never gets `LC_CTYPE` set so libraries that read locale environment variables (babel) find nothing. This is the same class of failure that got the original removal reverted in f871d043. Replace the template comment with those concrete reasons, and add a one-line `docker run` reproducer for the embedded case. Regenerate the Dockerfiles. --- 3.11/alpine3.23/Dockerfile | 4 ++++ 3.11/alpine3.24/Dockerfile | 4 ++++ 3.11/bookworm/Dockerfile | 4 ++++ 3.11/slim-bookworm/Dockerfile | 4 ++++ 3.11/slim-trixie/Dockerfile | 4 ++++ 3.11/trixie/Dockerfile | 4 ++++ 3.12/alpine3.23/Dockerfile | 4 ++++ 3.12/alpine3.24/Dockerfile | 4 ++++ 3.12/bookworm/Dockerfile | 4 ++++ 3.12/slim-bookworm/Dockerfile | 4 ++++ 3.12/slim-trixie/Dockerfile | 4 ++++ 3.12/trixie/Dockerfile | 4 ++++ 3.13/alpine3.23/Dockerfile | 9 +++++++++ 3.13/alpine3.24/Dockerfile | 9 +++++++++ 3.13/bookworm/Dockerfile | 9 +++++++++ 3.13/slim-bookworm/Dockerfile | 9 +++++++++ 3.13/slim-trixie/Dockerfile | 9 +++++++++ 3.13/trixie/Dockerfile | 9 +++++++++ 3.14/alpine3.23/Dockerfile | 9 +++++++++ 3.14/alpine3.24/Dockerfile | 9 +++++++++ 3.14/bookworm/Dockerfile | 9 +++++++++ 3.14/slim-bookworm/Dockerfile | 9 +++++++++ 3.14/slim-trixie/Dockerfile | 9 +++++++++ 3.14/trixie/Dockerfile | 9 +++++++++ 3.15/alpine3.23/Dockerfile | 9 +++++++++ 3.15/alpine3.24/Dockerfile | 9 +++++++++ 3.15/bookworm/Dockerfile | 9 +++++++++ 3.15/slim-bookworm/Dockerfile | 9 +++++++++ 3.15/slim-trixie/Dockerfile | 9 +++++++++ 3.15/trixie/Dockerfile | 9 +++++++++ 3.16-rc/alpine3.23/Dockerfile | 9 +++++++++ 3.16-rc/alpine3.24/Dockerfile | 9 +++++++++ 3.16-rc/slim-trixie/Dockerfile | 9 +++++++++ 3.16-rc/trixie/Dockerfile | 9 +++++++++ Dockerfile-linux.template | 7 ++++--- 35 files changed, 250 insertions(+), 3 deletions(-) diff --git a/3.11/alpine3.23/Dockerfile b/3.11/alpine3.23/Dockerfile index 21fd4c70c..517c5c645 100644 --- a/3.11/alpine3.23/Dockerfile +++ b/3.11/alpine3.23/Dockerfile @@ -10,8 +10,12 @@ FROM alpine:3.23 ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.11 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.11/alpine3.24/Dockerfile b/3.11/alpine3.24/Dockerfile index 76e41d417..2d9b4c568 100644 --- a/3.11/alpine3.24/Dockerfile +++ b/3.11/alpine3.24/Dockerfile @@ -10,8 +10,12 @@ FROM alpine:3.24 ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.11 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.11/bookworm/Dockerfile b/3.11/bookworm/Dockerfile index 106e28002..d5007a081 100644 --- a/3.11/bookworm/Dockerfile +++ b/3.11/bookworm/Dockerfile @@ -10,8 +10,12 @@ FROM buildpack-deps:bookworm ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.11 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.11/slim-bookworm/Dockerfile b/3.11/slim-bookworm/Dockerfile index 6fc35c4d5..7b5f38efc 100644 --- a/3.11/slim-bookworm/Dockerfile +++ b/3.11/slim-bookworm/Dockerfile @@ -10,8 +10,12 @@ FROM debian:bookworm-slim ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.11 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.11/slim-trixie/Dockerfile b/3.11/slim-trixie/Dockerfile index 3629f7644..d480e5e51 100644 --- a/3.11/slim-trixie/Dockerfile +++ b/3.11/slim-trixie/Dockerfile @@ -10,8 +10,12 @@ FROM debian:trixie-slim ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.11 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.11/trixie/Dockerfile b/3.11/trixie/Dockerfile index d90fb640a..3d4ae0d23 100644 --- a/3.11/trixie/Dockerfile +++ b/3.11/trixie/Dockerfile @@ -10,8 +10,12 @@ FROM buildpack-deps:trixie ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.11 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.12/alpine3.23/Dockerfile b/3.12/alpine3.23/Dockerfile index 0379fb14b..7e9434031 100644 --- a/3.12/alpine3.23/Dockerfile +++ b/3.12/alpine3.23/Dockerfile @@ -10,8 +10,12 @@ FROM alpine:3.23 ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.12 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.12/alpine3.24/Dockerfile b/3.12/alpine3.24/Dockerfile index 9470bbab6..66b4e977e 100644 --- a/3.12/alpine3.24/Dockerfile +++ b/3.12/alpine3.24/Dockerfile @@ -10,8 +10,12 @@ FROM alpine:3.24 ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.12 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.12/bookworm/Dockerfile b/3.12/bookworm/Dockerfile index a580001dd..77161177a 100644 --- a/3.12/bookworm/Dockerfile +++ b/3.12/bookworm/Dockerfile @@ -10,8 +10,12 @@ FROM buildpack-deps:bookworm ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.12 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.12/slim-bookworm/Dockerfile b/3.12/slim-bookworm/Dockerfile index 0658ea6df..474bb4d25 100644 --- a/3.12/slim-bookworm/Dockerfile +++ b/3.12/slim-bookworm/Dockerfile @@ -10,8 +10,12 @@ FROM debian:bookworm-slim ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.12 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.12/slim-trixie/Dockerfile b/3.12/slim-trixie/Dockerfile index b184625b8..6851c2efc 100644 --- a/3.12/slim-trixie/Dockerfile +++ b/3.12/slim-trixie/Dockerfile @@ -10,8 +10,12 @@ FROM debian:trixie-slim ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.12 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.12/trixie/Dockerfile b/3.12/trixie/Dockerfile index 409c1452c..fef58139b 100644 --- a/3.12/trixie/Dockerfile +++ b/3.12/trixie/Dockerfile @@ -10,8 +10,12 @@ FROM buildpack-deps:trixie ENV PATH /usr/local/bin:$PATH # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.12 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 # runtime dependencies diff --git a/3.13/alpine3.23/Dockerfile b/3.13/alpine3.23/Dockerfile index 424eb6f9d..c88143d9f 100644 --- a/3.13/alpine3.23/Dockerfile +++ b/3.13/alpine3.23/Dockerfile @@ -9,6 +9,15 @@ FROM alpine:3.23 # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.13 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apk add --no-cache \ diff --git a/3.13/alpine3.24/Dockerfile b/3.13/alpine3.24/Dockerfile index 14788257f..720a773fa 100644 --- a/3.13/alpine3.24/Dockerfile +++ b/3.13/alpine3.24/Dockerfile @@ -9,6 +9,15 @@ FROM alpine:3.24 # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.13 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apk add --no-cache \ diff --git a/3.13/bookworm/Dockerfile b/3.13/bookworm/Dockerfile index 0152e0195..4c7599475 100644 --- a/3.13/bookworm/Dockerfile +++ b/3.13/bookworm/Dockerfile @@ -9,6 +9,15 @@ FROM buildpack-deps:bookworm # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.13 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.13/slim-bookworm/Dockerfile b/3.13/slim-bookworm/Dockerfile index 046330be9..6bbeaea52 100644 --- a/3.13/slim-bookworm/Dockerfile +++ b/3.13/slim-bookworm/Dockerfile @@ -9,6 +9,15 @@ FROM debian:bookworm-slim # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.13 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.13/slim-trixie/Dockerfile b/3.13/slim-trixie/Dockerfile index f32081f1c..aa37cc9a5 100644 --- a/3.13/slim-trixie/Dockerfile +++ b/3.13/slim-trixie/Dockerfile @@ -9,6 +9,15 @@ FROM debian:trixie-slim # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.13 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.13/trixie/Dockerfile b/3.13/trixie/Dockerfile index eaf1e181c..342902cd4 100644 --- a/3.13/trixie/Dockerfile +++ b/3.13/trixie/Dockerfile @@ -9,6 +9,15 @@ FROM buildpack-deps:trixie # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.13 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.14/alpine3.23/Dockerfile b/3.14/alpine3.23/Dockerfile index fcbccaa81..698552738 100644 --- a/3.14/alpine3.23/Dockerfile +++ b/3.14/alpine3.23/Dockerfile @@ -9,6 +9,15 @@ FROM alpine:3.23 # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.14 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apk add --no-cache \ diff --git a/3.14/alpine3.24/Dockerfile b/3.14/alpine3.24/Dockerfile index 50bdfb6ff..9e740e194 100644 --- a/3.14/alpine3.24/Dockerfile +++ b/3.14/alpine3.24/Dockerfile @@ -9,6 +9,15 @@ FROM alpine:3.24 # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.14 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apk add --no-cache \ diff --git a/3.14/bookworm/Dockerfile b/3.14/bookworm/Dockerfile index df08d2388..9b454c937 100644 --- a/3.14/bookworm/Dockerfile +++ b/3.14/bookworm/Dockerfile @@ -9,6 +9,15 @@ FROM buildpack-deps:bookworm # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.14 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.14/slim-bookworm/Dockerfile b/3.14/slim-bookworm/Dockerfile index 39192728d..ac87e18f3 100644 --- a/3.14/slim-bookworm/Dockerfile +++ b/3.14/slim-bookworm/Dockerfile @@ -9,6 +9,15 @@ FROM debian:bookworm-slim # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.14 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.14/slim-trixie/Dockerfile b/3.14/slim-trixie/Dockerfile index 7425a1e18..6538b57b7 100644 --- a/3.14/slim-trixie/Dockerfile +++ b/3.14/slim-trixie/Dockerfile @@ -9,6 +9,15 @@ FROM debian:trixie-slim # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.14 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.14/trixie/Dockerfile b/3.14/trixie/Dockerfile index 492e66405..9646b9b48 100644 --- a/3.14/trixie/Dockerfile +++ b/3.14/trixie/Dockerfile @@ -9,6 +9,15 @@ FROM buildpack-deps:trixie # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.14 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.15/alpine3.23/Dockerfile b/3.15/alpine3.23/Dockerfile index 7544dec24..1d917edc0 100644 --- a/3.15/alpine3.23/Dockerfile +++ b/3.15/alpine3.23/Dockerfile @@ -9,6 +9,15 @@ FROM alpine:3.23 # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.15 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apk add --no-cache \ diff --git a/3.15/alpine3.24/Dockerfile b/3.15/alpine3.24/Dockerfile index daad35628..da1d2dfc8 100644 --- a/3.15/alpine3.24/Dockerfile +++ b/3.15/alpine3.24/Dockerfile @@ -9,6 +9,15 @@ FROM alpine:3.24 # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.15 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apk add --no-cache \ diff --git a/3.15/bookworm/Dockerfile b/3.15/bookworm/Dockerfile index 9428aad02..f002847e0 100644 --- a/3.15/bookworm/Dockerfile +++ b/3.15/bookworm/Dockerfile @@ -9,6 +9,15 @@ FROM buildpack-deps:bookworm # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.15 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.15/slim-bookworm/Dockerfile b/3.15/slim-bookworm/Dockerfile index f9bc43c52..22bbd6542 100644 --- a/3.15/slim-bookworm/Dockerfile +++ b/3.15/slim-bookworm/Dockerfile @@ -9,6 +9,15 @@ FROM debian:bookworm-slim # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.15 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.15/slim-trixie/Dockerfile b/3.15/slim-trixie/Dockerfile index 409e58c59..3d9576a9b 100644 --- a/3.15/slim-trixie/Dockerfile +++ b/3.15/slim-trixie/Dockerfile @@ -9,6 +9,15 @@ FROM debian:trixie-slim # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.15 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.15/trixie/Dockerfile b/3.15/trixie/Dockerfile index 525464355..1768537cb 100644 --- a/3.15/trixie/Dockerfile +++ b/3.15/trixie/Dockerfile @@ -9,6 +9,15 @@ FROM buildpack-deps:trixie # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.15 sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.16-rc/alpine3.23/Dockerfile b/3.16-rc/alpine3.23/Dockerfile index 935da0f4b..bda64853b 100644 --- a/3.16-rc/alpine3.23/Dockerfile +++ b/3.16-rc/alpine3.23/Dockerfile @@ -9,6 +9,15 @@ FROM alpine:3.23 # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.16-rc sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apk add --no-cache \ diff --git a/3.16-rc/alpine3.24/Dockerfile b/3.16-rc/alpine3.24/Dockerfile index b9a7af65d..25fbda7ce 100644 --- a/3.16-rc/alpine3.24/Dockerfile +++ b/3.16-rc/alpine3.24/Dockerfile @@ -9,6 +9,15 @@ FROM alpine:3.24 # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.16-rc sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apk add --no-cache \ diff --git a/3.16-rc/slim-trixie/Dockerfile b/3.16-rc/slim-trixie/Dockerfile index 8dca73628..96a241639 100644 --- a/3.16-rc/slim-trixie/Dockerfile +++ b/3.16-rc/slim-trixie/Dockerfile @@ -9,6 +9,15 @@ FROM debian:trixie-slim # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.16-rc sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/3.16-rc/trixie/Dockerfile b/3.16-rc/trixie/Dockerfile index 45055a827..66264ac4e 100644 --- a/3.16-rc/trixie/Dockerfile +++ b/3.16-rc/trixie/Dockerfile @@ -9,6 +9,15 @@ FROM buildpack-deps:trixie # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH +# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none +# last attempted removal of LANG broke many users: +# https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:3.16-rc sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' +ENV LANG C.UTF-8 + # runtime dependencies RUN set -eux; \ apt-get update; \ diff --git a/Dockerfile-linux.template b/Dockerfile-linux.template index f95548890..2509ecddb 100644 --- a/Dockerfile-linux.template +++ b/Dockerfile-linux.template @@ -25,14 +25,15 @@ FROM buildpack-deps:{{ env.variant }} # ensure local python is preferred over distribution python ENV PATH /usr/local/bin:$PATH -{{ if rcVersion | IN("3.11", "3.12") then ( -}} -{{ # only set LANG on versions less than 3.13 -}} # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed +# - embedded interpreters (uWSGI, mod_wsgi, etc) skip locale coercion and UTF-8 mode before Python 3.15, so they fall back to ASCII +# - musl (alpine) never gets LC_CTYPE set, so anything that reads locale environment variables (babel) finds none # last attempted removal of LANG broke many users: # https://github.com/docker-library/python/pull/570 +# embedded interpreter reproducer (fails with UnicodeEncodeError without LANG on 3.14 and earlier, needs a non-slim Debian variant for gcc): +# docker run --rm --env LANG= python:{{ env.version }} sh -c 'printf "#include \nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out' ENV LANG C.UTF-8 -{{ ) else "" end -}} # runtime dependencies {{ if is_alpine then ( -}} RUN set -eux; \