Closed Bug 671390 Opened 13 years ago Closed 13 years ago

nativegen.py unresolvable reference to clsfile in finally clause.

Categories

(Tamarin Graveyard :: Tools, defect)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: pnkfelix, Unassigned)

Details

Looking at this portion of changeset:5995

  http://hg.mozilla.org/tamarin-redux/diff/48b099e59e48/utils/nativegen.py#l1.596

one sees: 
if abcGenFor:
    hfile = None
    cppfile = None
    try:
        ...
    finally:
        ...
        if clsfile != None:
            clsfile.close()

The reference to clsfile in the finally block is unbound.

(This is causing problems with our attempt to validate the TR->FR merge.)
I snarkily observe that if the script had been written in AS3 and compiled in strict mode then that error would not have occured.
FYI, to actually expose the bug in practice, you probably need to be mucking about with file permissions.  (I had forgotten this and wasted time this morning wondering how I ended up here in the first place.)

Here's how to make it happen from a TR checkout:

% ( cd core && chmod -w ../generated/builtin.h && ./builtin.py )
ASC=/Users/fklockii/Dev/tamarin-redux/objdir-ged64/../utils/asc.jar
Building builtins...
builtin: 51207
Files: 11 Time: 3896ms
Generating native thunks...
Traceback (most recent call last):
  File "../utils/nativegen.py", line 2705, in <module>
    if clsfile != None:
NameError: name 'clsfile' is not defined


The point of fixing this bug is not to stop all exceptions from happening; its to stop the exception that is thrown from being hidden by the exception that later thrown by the finally clause as described in this ticket, so that the resulting stack trace is actually useful and the user can determine that builtin.h needs to be writable, like so:

Generating native thunks...
Traceback (most recent call last):
  File "../utils/nativegen.py", line 2693, in <module>
    hfile = open(abcGenName+".h","w")
IOError: [Errno 13] Permission denied: '../generated/builtin.h'
changeset: 6459:37a7f46ffed3
user:      Felix S Klock II <fklockii@adobe.com>
summary:   Bug 671390: introduce 'binding' for clsfile (r=fklockii).

http://hg.mozilla.org/tamarin-redux/rev/37a7f46ffed3
Status: NEW → RESOLVED
Closed: 13 years ago
Flags: flashplayer-qrb+
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.