# Actual parsing is way to slow, so we use regular expressions.
# The only catch is that we must strip comments and string
# literals ahead of time.
- source = Utils.open_source_file(source_filename, "rU").read()
+ fh = Utils.open_source_file(source_filename, "rU")
+ try:
+ source = fh.read()
+ finally:
+ fh.close()
distutils_info = DistutilsInfo(source)
source, literals = strip_string_literals(source)
source = source.replace('\\\n', ' ')
for key, value in literals.items():
module_code = module_code.replace(key, value)
pyx_file = os.path.join(lib_dir, module_name + '.pyx')
- open(pyx_file, 'w').write(module_code)
+ fh = open(pyx_file, 'w')
+ try:
+ fh.write(module_code)
+ finally:
+ fh.close()
extension = Extension(
name = module_name,
sources = [pyx_file],