Commit fd13c811 authored by Stefan Behnel's avatar Stefan Behnel

fix open file leak

--HG--
extra : transplant_source : 7%EC%04%1F%89%F6%AA%8C%7Fl%B5D%DA%D5%CAF%B7%A70%0D
parent 2e88bd48
...@@ -7,7 +7,7 @@ from __future__ import absolute_import ...@@ -7,7 +7,7 @@ from __future__ import absolute_import
import os import os
import re import re
import sys import sys
import codecs import io
if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[:2] < (3, 2): if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[:2] < (3, 2):
sys.stderr.write("Sorry, Cython requires Python 2.6+ or 3.2+, found %d.%d\n" % tuple(sys.version_info[:2])) sys.stderr.write("Sorry, Cython requires Python 2.6+ or 3.2+, found %d.%d\n" % tuple(sys.version_info[:2]))
...@@ -427,9 +427,10 @@ def run_pipeline(source, options, full_module_name=None, context=None): ...@@ -427,9 +427,10 @@ def run_pipeline(source, options, full_module_name=None, context=None):
# By default, decide based on whether an html file already exists. # By default, decide based on whether an html file already exists.
html_filename = os.path.splitext(result.c_file)[0] + ".html" html_filename = os.path.splitext(result.c_file)[0] + ".html"
if os.path.exists(html_filename): if os.path.exists(html_filename):
line = codecs.open(html_filename, "r", encoding="UTF-8").readline() with io.open(html_filename, "r", encoding="UTF-8") as html_file:
if line.startswith(u'<!-- Generated by Cython'): line = html_file.readline()
options.annotate = True if line.startswith(u'<!-- Generated by Cython'):
options.annotate = True
# Get pipeline # Get pipeline
if source_ext.lower() == '.py' or not source_ext: if source_ext.lower() == '.py' or not source_ext:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment