Commits

Oleg Oshmyan committed 715e352

Fixed crashing on testconfs inside archives on Python 3

Comments (0)

Files changed (1)

upreckon/config.py

-# Copyright (c) 2010-2011 Chortos-2 <chortos@inbox.lv>
+# Copyright (c) 2010-2012 Chortos-2 <chortos@inbox.lv>
 
 from __future__ import division, with_statement
 
 				with metafile.open() as f:
 					module = imp.load_module('testconf', f, metafile.full_real_path, ('.py', 'r', imp.PY_SOURCE))
 			# Handle the case when f is not a true file object but imp requires one
-			except ValueError:
+			# TypeError on Python 3, ValueError on Python 2
+			except (TypeError, ValueError):
 				# FIXME: 2.5 lacks the delete parameter
 				with tempfile.NamedTemporaryFile(delete=False) as f:
 					inputdatafname = f.name
 				with metafile.open() as f:
 					module = imp.load_module('testconf', f, metafile.full_real_path, ('.py', 'r', imp.PY_SOURCE))
 			# Handle the case when f is not a true file object but imp requires one
-			except ValueError:
+			# TypeError on Python 3, ValueError on Python 2
+			except (TypeError, ValueError):
 				# FIXME: 2.5 lacks the delete parameter
 				with tempfile.NamedTemporaryFile(delete=False) as f:
 					inputdatafname = f.name