Opened 3 weeks ago

Closed 4 days ago

#37110 closed Cleanup/optimization (fixed)

Use `zoneinfo` for validating `TIME_ZONE` setting instead of `Path("/usr/share/zoneinfo")`

Reported by: jodizzle Owned by: jodizzle
Component: Core (Other) Version: dev
Severity: Normal Keywords: settings
Cc: jodizzle Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

On my system, I receive failures in the test suite related to the setting of TIME_ZONE, e.g., `test_incorrect_timezone`. The root issue is that Django validates `TIME_ZONE` against a hardcoded "/usr/share/zoneinfo" path which does not exist on my system.

Thankfully, Python has standard library support for validating timezones via the `zoneinfo` module. This module was introduced in Python 3.9, meaning all modern Django versions should support it's use.

I've attached the patch that fixes my test failures. I can submit a PR if this ticket is accepted.

Attachments (1)

zoneinfo-patch.diff (1.2 KB ) - added by jodizzle 3 weeks ago.

Download all attachments as: .zip

Change History (11)

by jodizzle, 3 weeks ago

Attachment: zoneinfo-patch.diff added

comment:1 by jodizzle, 3 weeks ago

Owner: set to jodizzle

comment:2 by jodizzle, 3 weeks ago

Component: UncategorizedTesting framework

comment:3 by jodizzle, 3 weeks ago

Type: UncategorizedBug

comment:4 by Sarah Boyce, 3 weeks ago

Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Refs #3415
Thank you for the suggestion

comment:5 by Jacob Walls, 5 days ago

Terrific -- could you convert your patch to a GitHub pull request?

comment:6 by jodizzle, 5 days ago

Yes, sorry for the delay. I'll do so soon.

comment:7 by Mike Edmunds, 5 days ago

Component: Testing frameworkCore (Other)
Keywords: settings added

comment:9 by Jacob Walls, 4 days ago

Triage Stage: AcceptedReady for checkin

comment:10 by Jacob Walls <jacobtylerwalls@…>, 4 days ago

Resolution: fixed
Status: assignedclosed

In 8c2d3dca:

Fixed #37110 -- Fixed time zone validation when missing zone directory.

On Unix systems that lack time zone information stored at
/usr/share/zoneinfo, time zones couldn't be validated.

Python's zoneinfo module was introduced in Python 3.9, meaning all
modern Django versions should support it's use.

Note: See TracTickets for help on using tickets.
Back to Top