Skip to content

Instantly share code, notes, and snippets.

@modocache
Created February 16, 2014 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save modocache/9031335 to your computer and use it in GitHub Desktop.
Save modocache/9031335 to your computer and use it in GitHub Desktop.
Index: tests/cindex/test_translation_unit.py
===================================================================
--- tests/cindex/test_translation_unit.py (revision 201083)
+++ tests/cindex/test_translation_unit.py (working copy)
@@ -1,5 +1,6 @@
import gc
import os
+import tempfile
from clang.cindex import CursorKind
from clang.cindex import Cursor
@@ -93,15 +94,7 @@
Returns the filename it was saved to.
"""
-
- # FIXME Generate a temp file path using system APIs.
- base = 'TEMP_FOR_TRANSLATIONUNIT_SAVE.c'
- path = os.path.join(kInputsDir, base)
-
- # Just in case.
- if os.path.exists(path):
- os.unlink(path)
-
+ _, path = tempfile.mkstemp()
tu.save(path)
return path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment