Skip to content

Commit 27265f7

Browse files
committed
When possible, sanity check the timezone setting to see if the Unix-like
box it's running on supports that setting. If checking isn't possible, we skip it. Patch from seveas. Thanks. Fixed #3415. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13722 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 255147c commit 27265f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

django/conf/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ def __init__(self, settings_module):
103103
self.INSTALLED_APPS = new_installed_apps
104104

105105
if hasattr(time, 'tzset') and getattr(self, 'TIME_ZONE'):
106+
# When we can, attempt to validate the timezone. If we can't find
107+
# this file, no check happens and it's harmless.
108+
zoneinfo_root = '/usr/share/zoneinfo'
109+
if (os.path.exists(zoneinfo_root) and not
110+
os.path.exists(os.path.join(zoneinfo_root, *(self.TIME_ZONE.split('/'))))):
111+
raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
106112
# Move the time zone info into os.environ. See ticket #2315 for why
107113
# we don't do this unconditionally (breaks Windows).
108114
os.environ['TZ'] = self.TIME_ZONE

0 commit comments

Comments
 (0)