durusmail: quixote-users: Removing pltc files on compilation failures, fails.
Removing pltc files on compilation failures, fails.
2003-03-17
Re: Removing pltc files on compilation failures, fails.
2003-03-17
Re: Removing pltc files on compilation failures, fails.
2003-03-17
Re: Removing pltc files on compilation failures, fails.
2003-03-17
Re: Removing pltc files on compilation failures, fails.
2003-03-17
Removing pltc files on compilation failures, fails.
2003-03-17
Removing pltc files on compilation failures, fails.
2003-03-17
Removing pltc files on compilation failures, fails.
David Ascher
2003-03-17
The _load_ptl code in ptl_import.py results in 'unhelpful' tracebacks on
Windows (in at least some circumstances), in the case of a syntax error in a
PTL file.

Briefly, the last part of that function:

     try:
         code = compile_template(file, filename, output)
     except:
         # don't leave a corrupt .ptlc file around
         if output:
             output.close()
             os.unlink(ptlc_filename)
         raise
     return _new_module(code, name, filename)


fails in the event of a SyntaxError, on at least three Win2k machines, with
the os.unlink() call raising an OSError, "Permission denied".  I haven't been
able to figure out why that happens, but in the meantime am running with code
like:

     try:
         code = compile_template(file, filename, output)
     except:
         exc_type, exc_value, traceback = sys.exc_info()
         # don't leave a corrupt .ptlc file around
         if output:
             output.close()
             try:
                 os.unlink(ptlc_filename)
                 # on Windows this fails with a permission denied,
                 # don't know why
             except OSError:
                 pass
         raise exc_type, exc_value
     return _new_module(code, name, filename)

which lets me get to the SyntaxError exception.

Does anyone know why the ptcl_filename would still have a lock on it?  I don't
understand enough of how the compiler package works to know why it would hold
on to the output file after an output.close().

--david


reply