Skip to content

Set LANG on all Linux variants again, including 3.13+ - #1145

Merged
yosifkit merged 1 commit into
docker-library:masterfrom
infosiftr:LANG
Oct 23, 2026
Merged

yosifkit merged 1 commit into
docker-library:masterfrom
infosiftr:LANG

Conversation

@tianon

@tianon tianon commented Oct 23, 2026

Copy link
Copy Markdown
Member

Restore ENV LANG C.UTF-8 on 3.13 and later, undoing the 3.13+ part of 0d53911. 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 f871d04.

Replace the template comment with those concrete reasons, and add a one-line docker run reproducer for the embedded case. Regenerate the Dockerfiles.

Refs:

Restore `ENV LANG C.UTF-8` on 3.13 and later, undoing the 3.13+ part of 0d53911.  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 f871d04.

Replace the template comment with those concrete reasons, and add a one-line `docker run` reproducer for the embedded case.  Regenerate the Dockerfiles.
Comment thread Dockerfile-linux.template
# 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 <Python.h>\nint main(){Py_Initialize();PyRun_SimpleString(\"print(chr(252),flush=True)\");}" | gcc -x c - $(python3-config --embed --cflags --ldflags) && ./a.out'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think about #1144 (comment) in the context of this change too, but IMO these are useful enough context additions that they're worth getting into the provenance on the existing images (and the Linux images are a lot lighter on Hub, even if they're heavier on the build systems).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the plus side, the ones they're heaviest on should have some build cache. 🤞

@yosifkit
yosifkit merged commit d01180b into docker-library:master Oct 23, 2026
44 checks passed
@yosifkit
yosifkit deleted the LANG branch October 23, 2026 23:43
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Oct 23, 2026
Changes:

- docker-library/python@d01180b5: Set LANG on all Linux variants again, including 3.13+ (docker-library/python#1145)
- docker-library/python@6c812a5b: Drop PYTHONIOENCODING for Python >= 3.16 (docker-library/python#1144)
- docker-library/python@bd0f6ae1: Add 3.16-rc windows variants (docker-library/python#1139)
taylorific added a commit to boxcutter/oci that referenced this pull request Oct 24, 2026
Update Python to 3.11.17, 3.12.15, 3.13.17 and 3.14.9, add 3.15.1
(noble and slim-noble), and move the slim base images to
ubuntu:jammy-20260930 and ubuntu:noble-20260930.1. Drop 3.9 and 3.10,
which are EOL and have been removed upstream.

Bring the Containerfiles in line with upstream:
- set LANG=C.UTF-8 on 3.13 and later again, with upstream's new comment
  explaining why it can't be dropped (docker-library/python#1145)
- append -Wl,-rpath and -Wl,--strip-all after LDFLAGS rather than
  relying on it ending in a -Wl option
- add g++ to the slim build deps so C++ extensions build
- build 3.14+ full images with libzstd-dev so compression.zstd works
- bump setuptools to 79.0.1 and wheel to 0.46.3 on 3.11
- build 3.15 with --without-system-libmpdec, as upstream does on
  bookworm, since noble has no libmpdec-dev
- match upstream's indentation of the frame-pointer case block

Fix the slim build-dep cleanup, which flipped the runtime libraries the
ldd scan had just marked manual back to auto, so the purge removed
libsqlite3-0, libreadline8 and friends and "import sqlite3" failed on
every published slim image. The new manuals are now reset to auto
before the ldd scan.

Also update the CI path filters for the added and removed versions, add
the missing hadolint ignore to 3.12/slim-noble, fix the indentation of
the 3.13 and 3.14 bake files, and strip trailing whitespace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants