r201762 - [libclang/python] Use a Python standard library module to create a temporary file.

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Feb 19 23:24:03 PST 2014


Author: akirtzidis
Date: Thu Feb 20 01:24:03 2014
New Revision: 201762

URL: http://llvm.org/viewvc/llvm-project?rev=201762&view=rev
Log:
[libclang/python] Use a Python standard library module to create a temporary file.

Patch by Brian Gesiak!

Modified:
    cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py?rev=201762&r1=201761&r2=201762&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py Thu Feb 20 01:24:03 2014
@@ -1,5 +1,6 @@
 import gc
 import os
+import tempfile
 
 from clang.cindex import CursorKind
 from clang.cindex import Cursor
@@ -93,15 +94,7 @@ def save_tu(tu):
 
     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





More information about the cfe-commits mailing list