From 341dcb8a0c6504cbeb8462ad416deefec2ee748e Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Tue, 14 Apr 2009 17:39:38 -0300 Subject: [PATCH] fix error when Lexicon source file cannot be open (Cython inside a ZIP file) --- Cython/Compiler/Scanning.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Scanning.py b/Cython/Compiler/Scanning.py index 059e32e3..d5eae3b6 100644 --- a/Cython/Compiler/Scanning.py +++ b/Cython/Compiler/Scanning.py @@ -48,6 +48,7 @@ def hash_source_file(path): from hashlib import md5 as new_md5 except ImportError: from md5 import new as new_md5 + f = None try: try: f = open(path, "rU") @@ -56,7 +57,8 @@ def hash_source_file(path): print("Unable to hash scanner source file (%s)" % e) return "" finally: - f.close() + if f: + f.close() # Normalise spaces/tabs. We don't know what sort of # space-tab substitution the file may have been # through, so we replace all spans of spaces and -- 2.26.2