Yet another fix of the patch

This commit is contained in:
Matěj Cepl 2016-07-21 08:52:32 +02:00
parent e6a0d42125
commit 8686bd9e27

View File

@ -9,15 +9,18 @@
__all__ = [
'timezone', 'utc', 'country_timezones', 'country_names',
@@ -77,23 +77,16 @@ def open_resource(name):
Uses the pkg_resources module if available and no standard file
found at the calculated location.
"""
+ _tzinfo_dir = os.getenv("TZDIR") or "/usr/share/zoneinfo"
+ if _tzinfo_dir.endswith(os.sep):
+ _tzinfo_dir = _tzinfo_dir[:-1]
@@ -70,6 +70,10 @@ else: # Python 2.x
"""
return s.encode('ASCII')
+_tzinfo_dir = os.getenv("TZDIR") or "/usr/share/zoneinfo"
+if _tzinfo_dir.endswith(os.sep):
+ _tzinfo_dir = _tzinfo_dir[:-1]
+
name_parts = name.lstrip('/').split('/')
def open_resource(name):
"""Open a resource from the zoneinfo subdir for reading.
@@ -81,19 +85,8 @@ def open_resource(name):
for part in name_parts:
if part == os.path.pardir or os.path.sep in part:
raise ValueError('Bad path segment: %r' % part)