From 4f3014960669634b07a37cf468d9890541fd9890 Mon Sep 17 00:00:00 2001 From: Yaron de Leeuw Date: Thu, 27 Nov 2014 22:28:28 +0200 Subject: gracefully fail on missing zoneinfo, to allow "bootstaping" for updatezinfo --- dateutil/zoneinfo/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'dateutil/zoneinfo') 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): -- cgit v1.2.3