summaryrefslogtreecommitdiff
path: root/django/conf/__init__.py
diff options
context:
space:
mode:
authorTom <tom@tomforb.es>2017-07-21 21:33:26 +0100
committerTim Graham <timograham@gmail.com>2018-04-19 21:30:00 -0400
commit11b8c30b9e02ef6ecb996ad3280979dfeab700fa (patch)
treea086c9dc9bfe15f58da7db1393f122e690d5a670 /django/conf/__init__.py
parent5d923f2d8cadb06497d255097caa4583d66b697a (diff)
Ref #23919 -- Replaced some os.path usage with pathlib.Path.
Diffstat (limited to 'django/conf/__init__.py')
-rw-r--r--django/conf/__init__.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index 6813afb3b8..9b3e350a50 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -10,6 +10,7 @@ import importlib
import os
import time
import warnings
+from pathlib import Path
from django.conf import global_settings
from django.core.exceptions import ImproperlyConfigured
@@ -130,9 +131,9 @@ class Settings:
if hasattr(time, 'tzset') and self.TIME_ZONE:
# When we can, attempt to validate the timezone. If we can't find
# this file, no check happens and it's harmless.
- zoneinfo_root = '/usr/share/zoneinfo'
- if (os.path.exists(zoneinfo_root) and not
- os.path.exists(os.path.join(zoneinfo_root, *(self.TIME_ZONE.split('/'))))):
+ zoneinfo_root = Path('/usr/share/zoneinfo')
+ zone_info_file = zoneinfo_root.joinpath(*self.TIME_ZONE.split('/'))
+ if zoneinfo_root.exists() and not zone_info_file.exists():
raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
# Move the time zone info into os.environ. See ticket #2315 for why
# we don't do this unconditionally (breaks Windows).