Skip to content
This repository was archived by the owner on Apr 2, 2019. It is now read-only.

Commit f8aaad3

Browse files
committed
Make external Python work on Windows
1 parent e20e449 commit f8aaad3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

checker.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ def get_style_problems(source, filename):
6363
def get_external(source, filename, executable):
6464
import json
6565
import subprocess
66-
with tempfile.NamedTemporaryFile() as tf:
67-
tf.write(source.encode('utf-8'))
66+
tf = tempfile.NamedTemporaryFile(delete=False)
67+
tf.write(source.encode('utf-8'))
68+
tf.close()
69+
try:
6870
output = subprocess.check_output([executable,
6971
os.path.dirname(__file__),
7072
tf.name, filename])
73+
finally:
74+
os.unlink(tf.name)
7175
problems = json.loads(output.decode('utf-8'))
7276
problems = [Problem(*p) for p in problems]
7377
return problems

0 commit comments

Comments
 (0)