[pypy-dev] File overwriting (--output flag to translate.py)

pypy at pocketnix.org pypy at pocketnix.org
Tue Apr 12 10:57:52 CEST 2011


On Mon, Apr 11, 2011 at 09:27:09PM +0200, Armin Rigo wrote:
> 
> Sadly everyone so far has his own additional hacks to categorize
> multiple translated versions.  Mine is to ignore the pypy-c entirely
> and copy the executable from the /tmp, after it has been produced
> there.  I also copy the C sources (but not the other files produced by
> gcc).  Anyway, my point is that the particular change you are
> proposing would actually harm me, because I always have a pypy-c and
> I'm fine if it gets overwritten by every translation :-)
> 
> We need to think of some better solution...
> 
> Armin

here is an updated version that specifically checks if the destination 
specified by the --output flag is the same as the running interpreter, 
this matches the error i was having more closely and should hopefully 
not interfere with other users work flows

of course i am assuming here that you are not relying on the pdb 
shell as a notification to copy the file over, if you do feel free to 
ignore this updated patch

- Da_Blitz
-------------------------------------------------------------
Double check to ensure we are not overwriting the current interpreter

--- a/pypy/translator/goal/translate.py
+++ b/pypy/translator/goal/translate.py
@@ -285,6 +285,10 @@
         elif drv.exe_name is None and '__name__' in targetspec_dic:
             drv.exe_name = targetspec_dic['__name__'] + '-%(backend)s'
 
+        # Double check to ensure we are not overwriting the current interpreter
+        if os.path.realpath(drv.exe_name) == sys.executable:
+            raise ValueError('File "' + drv.exe_name+ '" already exisits (--output)')
+
         goals = translateconfig.goals
         try:
             drv.proceed(goals)
 



More information about the Pypy-dev mailing list