Skip to content

Set sysconfig TZPATH on POSIX so zoneinfo finds system time zones - #1207

Merged
graalvmbot merged 1 commit into
oracle:masterfrom
graemerocher:GH1206-tzpath
Oct 13, 2026
Merged

graalvmbot merged 1 commit into
oracle:masterfrom
graemerocher:GH1206-tzpath

Conversation

@graemerocher

Copy link
Copy Markdown
Member

Fixes #1206.

zoneinfo falls back to sysconfig.get_config_var("TZPATH") when PYTHONTZPATH isn't set. CPython's configure sets that variable to its --with-tzpath default, /usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo. GraalPy defines it only on Windows (as ''), so on Linux and macOS zoneinfo.TZPATH is () and system time zones are never found.

This change sets the same default in _sysconfig._update_posix_vars for non-Windows platforms. It uses _setdefault, so a TZPATH in the generated _sysconfigdata still wins. The new test in test_sysconfig.py checks the config var and zoneinfo.TZPATH in a fresh interpreter without PYTHONTZPATH.

Verified on GraalPy 25.4.4 (macOS): sysconfig.get_config_var('TZPATH') is None and zoneinfo.TZPATH is () today. With this search path, ZoneInfo('Europe/Berlin') resolves from /usr/share/zoneinfo. I checked the new _update_posix_vars output directly, but I haven't run the full mx test suite.

zoneinfo falls back to sysconfig's TZPATH, which CPython's configure sets
to /usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo
by default. GraalPy did not define it, so zoneinfo.TZPATH was empty and
ZoneInfo needed the tzdata package. Windows keeps an empty TZPATH.

Fixes oracle#1206

Signed-off-by: Graeme Rocher <graeme.rocher@oracle.com>
@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 9, 2026
@graalvmbot
graalvmbot merged commit 6bd6b96 into oracle:master Oct 13, 2026
41 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zoneinfo.TZPATH is empty on POSIX: sysconfig TZPATH is not set

3 participants