diff options
author | Yaron de Leeuw <me@jarondl.net> | 2014-11-27 22:28:28 +0200 |
---|---|---|
committer | Yaron de Leeuw <me@jarondl.net> | 2014-11-27 22:28:28 +0200 |
commit | 4f3014960669634b07a37cf468d9890541fd9890 (patch) | |
tree | 2cd2b61f1f1e8b48d1d9d630421b669b8f208eb8 /dateutil/zoneinfo | |
parent | b759afd4f3a17ab9b3d9107f5d9cce350da51bee (diff) | |
download | dateutil-4f3014960669634b07a37cf468d9890541fd9890.tar.gz |
gracefully fail on missing zoneinfo, to allow "bootstaping" for updatezinfo
Diffstat (limited to 'dateutil/zoneinfo')
-rw-r--r-- | dateutil/zoneinfo/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/dateutil/zoneinfo/__init__.py b/dateutil/zoneinfo/__init__.py index e1b377e..4782311 100644 --- a/dateutil/zoneinfo/__init__.py +++ b/dateutil/zoneinfo/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import logging import os +import warnings from subprocess import check_call from tarfile import TarFile from pkgutil import get_data @@ -17,7 +18,11 @@ class tzfile(tzfile): return (gettz, (self._filename,)) def getzoneinfofile_stream(): - return BytesIO(get_data(__name__, _ZONEFILENAME)) + try: + return BytesIO(get_data(__name__, _ZONEFILENAME)) + except IOError as e: # TODO switch to FileNotFoundError? + warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) + return None class ZoneInfoFile(object): def __init__(self, zonefile_stream=None): |