From b403f741e724940ccd2f86a01df35d6d7abbee7e Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Fri, 4 Jan 2013 16:46:31 +0200 Subject: [PATCH] TransRead: catch ValueError exceptions Sometimes urllib2 throws ValueError exceptions when it cannot open a local file. Catch it as well. Change-Id: I1f5707ad37d079368a2bf4b3ed3d092c43064387 Signed-off-by: Artem Bityutskiy --- bmaptools/TransRead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bmaptools/TransRead.py b/bmaptools/TransRead.py index 51192c7..c4d19d1 100644 --- a/bmaptools/TransRead.py +++ b/bmaptools/TransRead.py @@ -206,7 +206,7 @@ class TransRead: opener.addheaders = [('User-Agent', 'Mozilla/5.0')] urllib2.install_opener(opener) self._file_obj = opener.open(filepath) - except IOError as err: + except (IOError, ValueError) as err: raise Error("cannot open URL '%s': %s" % (filepath, err)) self.is_url = True -- 2.7.4