Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix compatibility with python 2.5.

By not using anymore the delete argument of NamedTemporaryFile, it
is possible to have coccigrep running with python 2.5.
  • Loading branch information...
commit 0db22aeae07c40081e4e07988f7a1834b2fe9598 1 parent b89d209
Eric Leblond authored November 05, 2011

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. 6  src/coccigrep.py
6  src/coccigrep.py
@@ -421,7 +421,7 @@ def run(self, files):
421 421
                 raise CocciRunException("'%s' is not a file, can't "
422 422
                     "continue" % cfile)
423 423
         # create tmp cocci file:
424  
-        tmp_cocci_file = NamedTemporaryFile(suffix=".cocci", delete=False)
  424
+        tmp_cocci_file = NamedTemporaryFile(suffix=".cocci")
425 425
         tmp_cocci_file_name = tmp_cocci_file.name
426 426
         # open file with name matching operation
427 427
         cocci_file = open(self.operations[self.operation], 'r')
@@ -434,7 +434,7 @@ def run(self, files):
434 434
         cocci_grep = cocci_smpl + CocciGrep.cocci_python
435 435
 
436 436
         tmp_cocci_file.write(cocci_grep)
437  
-        tmp_cocci_file.close()
  437
+        tmp_cocci_file.flush()
438 438
 
439 439
         # launch spatch
440 440
         output = ""
@@ -466,6 +466,7 @@ def run(self, files):
466 466
                     continue
467 467
                 import pickle
468 468
                 err = pickle.loads(ret)
  469
+                tmp_cocci_file.close()
469 470
                 unlink(tmp_cocci_file_name)
470 471
                 _raise_run_err(err, cmd)
471 472
         # Fallback to one spatch
@@ -484,6 +485,7 @@ def run(self, files):
484 485
                 unlink(tmp_cocci_file_name)
485 486
                 _raise_run_err(err, cmd)
486 487
 
  488
+            tmp_cocci_file.close()
487 489
             unlink(tmp_cocci_file_name)
488 490
 
489 491
         prevfile = None

0 notes on commit 0db22ae

Please sign in to comment.
Something went wrong with that request. Please try again.