[pypy-dev] File overwriting (--output flag to translate.py)
pypy at pocketnix.org
pypy at pocketnix.org
Mon Apr 11 14:45:41 CEST 2011
Hi again
i have been compiling a bunch of different pypy instances with different
levels of optimizations and features and found that if i run pypy-c
from the current directory and dont specify a new output filename it
will attempt to and fail to overwrite pypy-c due to the file being "in
use". unfortunately the exception generated is in the shutil lib from
mem and the error message/exception does not give away immediately what
the cause is which can lead to some frustration on some of the longer
compiles ;)
its quick and dirty and i don't mind if it gets changed at all. not
100% sure what the correct way to report an error and abandon is other
than what everything else does (uncaught exception to a pdb shell)
--- 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'
+ # Ensure the file does not exisit else we fail at end of translation
+ if os.path.isfile(drv.exe_name):
+ raise ValueError('File "' + drv.exe_name+ '" already exisits (--output)')
+
goals = translateconfig.goals
try:
drv.proceed(goals)
More information about the Pypy-dev
mailing list