From: Lisandro Dalcin Date: Tue, 14 Apr 2009 20:39:38 +0000 (-0300) Subject: fix error when Lexicon source file cannot be open (Cython inside a ZIP file) X-Git-Tag: 0.11.1~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=341dcb8a0c6504cbeb8462ad416deefec2ee748e;p=cython.git fix error when Lexicon source file cannot be open (Cython inside a ZIP file) --- 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