[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-07-21 Thread Amaury Forgeot d'Arc

Changes by Amaury Forgeot d'Arc [EMAIL PROTECTED]:


Added file: http://bugs.python.org/file10953/localstofast.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-07-21 Thread Amaury Forgeot d'Arc

Changes by Amaury Forgeot d'Arc [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file10707/localstofast.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-07-21 Thread Amaury Forgeot d'Arc

Changes by Amaury Forgeot d'Arc [EMAIL PROTECTED]:


--
assignee:  - amaury.forgeotdarc

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-07-21 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment:

Committed as r65177.

--
resolution:  - fixed
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-06-23 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment:

The problem seems to have been introduced by r53954.

--
nosy: +amaury.forgeotdarc

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-06-23 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment:

The problem is in PyFrame_LocalsToFast.

(As I understand it: Locals refers to the locals() dictionary of the
frame; Fast refers to an optimization where local variables are stored
in an array. 
Each call to locals() or the trace function normalizes data by copying
the Fast array into the Locals dictionary; with sys.settrace, the user
may modify the locals, so the inverse transformation is done after each
call to the trace function)

When defining a class, PyFrame_FastToLocals does not copy the free
variables from enclosing scopes. This is the goal of r53954 Do not copy
free variables to locals in class namespaces.
When executing code in the class body, the sys.settrace function is
called with this reduced set of locals().
The problem is that PyFrame_LocalsToFastdoes does not have the same
test, and uses the locals() to update (and clear) the free variables as
well.

I attach a patch that makes PyFrame_LocalsToFast symmetric to
PyFrame_FastToLocals: in the case of a class statement, do not update 
the free variables.

--
keywords: +patch
nosy: +jhylton
Added file: http://bugs.python.org/file10707/localstofast.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-06-21 Thread alejandro david weil

alejandro david weil [EMAIL PROTECTED] added the comment:

Shorter trigger code..

--
nosy: +tenuki
Added file: http://bugs.python.org/file10698/test_broken3.py

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-06-21 Thread alejandro david weil

alejandro david weil [EMAIL PROTECTED] added the comment:

Some debugging helper code and my conclutions of one work day:
debughelper.tgZ:
-test_broken1/2.py  
   one does triggers the bug, the other doesn't)
-rtest.sh 
   executes boths and compares its outputs
-frameobject.c.diff
   applied to Objects/frameobject.c, adds some debug info.

What I found:
1. The CustomException is disappearing from locals()
2. PyFrame_FastToLocals() (from that .c file) is updating the locals, 
and removing that exception from there.
3. In the failing case this code:
if (deref) {
assert(PyCell_Check(value));
value = PyCell_GET(value);
}
 is returning value==NULL.

Don't know why that happens.
But you could inspect out1.txt/out2.txt made with rtest.sh, and could 
discover something..

Added file: http://bugs.python.org/file10699/debughelper.tgz

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-05-11 Thread Nikolas Coukouma

Nikolas Coukouma [EMAIL PROTECTED] added the comment:

I can't reproduce this with r63075...

--
nosy: +nikolasco

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-05-11 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

I get it with r63075, r63085, on Linux.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-05-10 Thread Pedro Werneck

Pedro Werneck [EMAIL PROTECTED] added the comment:

Just note the error happens even without the try/except block inside the
'if' statement.

--
nosy: +werneck

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-03-17 Thread Jerry Seutter

New submission from Jerry Seutter [EMAIL PROTECTED]:

Found a bug when trying to integrate figleaf coverage into trunk.  I
have ripped the code down to the smallest subset that still causes the
behaviour.  The code works on the latest release of Python 2.5 but is
broken on trunk.  It comes in two files.  The first is the caller (figleaf):

import os
import sys

def foo(f, e, o):
pass

sys.settrace(foo)

import __main__
execfile('test_broken.py', __main__.__dict__)



The second file is the test (test_broken.py):

# This code breaks on trunk

def test_foo():
class CustomException(Exception):
pass

class SomeClass:
def foo(self):
raise CustomException

# The error only appears with enough nested blocks.
if (True == True):
try:
raise IOError
except CustomException:
pass



It should raise IOError.  When run, it gives the following output:

jerry-seutters-computer:~/code/python/core_wierd_bug_minimal jseutter$
../core/python.exe figleaf
Traceback (most recent call last):
  File figleaf, line 10, in module
execfile('test_broken.py', __main__.__dict__)
  File test_broken.py, line 18, in module
test_foo()
  File test_broken.py, line 15, in test_foo
except CustomException:
UnboundLocalError: local variable 'CustomException' referenced before
assignment
[10019 refs]

--
files: core_wierd_bug_minimal.zip
messages: 63856
nosy: jseutter
severity: normal
status: open
title: UnboundLocalError when trying to raise exceptions inside execfile
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file9716/core_wierd_bug_minimal.zip

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2378] UnboundLocalError when trying to raise exceptions inside execfile

2008-03-17 Thread Jerry Seutter

Changes by Jerry Seutter [EMAIL PROTECTED]:


--
components: +Interpreter Core

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2378
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com