[issue13557] exec of list comprehension fails on NameError

2012-07-08 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset ab22ffa6fb2e by Terry Jan Reedy in branch '2.7':
Issue #13557: Clarify effect of giving two different namespaces to exec or
http://hg.python.org/cpython/rev/ab22ffa6fb2e

New changeset ea670d71a36d by Terry Jan Reedy in branch '3.2':
Issue #13557: Clarify effect of giving two different namespaces to exec or
http://hg.python.org/cpython/rev/ea670d71a36d

New changeset b47ae7a9e685 by Terry Jan Reedy in branch 'default':
Merge 3.2 closes issue 13557
http://hg.python.org/cpython/rev/b47ae7a9e685

--
nosy: +python-dev
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2012-07-07 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
nosy: +Trundle, anikom15, daniel.urban, flox, jonathan.hartley, josmiley, 
michael.foord, mjs0, rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2012-07-07 Thread Florent Xicluna

Florent Xicluna florent.xicl...@gmail.com added the comment:

Issue #11796 marked as duplicate of this one.

However the issue described in #11796 does not involve exec/execfile.
It is about scopes for list comprehension like this one.

Another doc patch should probably be written to cover the case described in 
#11796 too.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2012-02-24 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Issues like this, about exec, have come up multiple times. I just closed #14049 
as a duplicate of this, and listed there some other issues. So I think that the 
doc for exec (and execfile in 2.7) could be better still. I would like to see 
something like the following added, whether instead of or in addition to the 
current proposal -- perhaps after If provided, locals can be any mapping 
object. (quote from the 3.2 exec entry)

At module level, globals and locals are the same dictionary. If one passes two 
separate objects as globals and locals, the code will be executed as if it were 
embedded in a class definition.

To me, this is friendlier and less intimidating than 'free variable' and the 
Execution model doc chapter. It summarizes the essential problem with such exec 
calls.

To illustrate, the following gives the same NameError. and for the same reason, 
as exec(code,{},{}), where code is the quoted unindented version with the class 
line deleted.

class x:
x = 1
def incx():
return x+1
print(incx())

--
nosy: +terry.reedy
versions: +Python 2.7, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2012-02-24 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Stefan: This fell off my radar, sorry I haven’t reviewed your patch yet.

Terry: +1

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2011-12-12 Thread Stephan R.A. Deibel

Stephan R.A. Deibel sdei...@wingware.com added the comment:

Here's a patch to the docs that notes the issue and refers the reader to the 
relevant execution model docs page.  I have also attempted to clarify the 
interaction with dynamic features section of the execution model page.

--
keywords: +patch
versions:  -Python 2.7, Python 3.2
Added file: http://bugs.python.org/file23937/exec-eval-clarification.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2011-12-10 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Would you like to make a doc patch?

--
assignee:  - docs@python
components: +Documentation
keywords: +easy
nosy: +docs@python, eric.araujo
resolution: invalid - 
stage:  - needs patch
versions: +Python 2.7, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2011-12-09 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

This is expected and documented: 
http://docs.python.org/py3k/reference/executionmodel.html#interaction-with-dynamic-features
Free variables are not resolved in the nearest enclosing namespace, but in the 
global namespace., a free variable being a variable used in a code block but 
not defined there.
And yes, a list comprehension defines a code block.

Try using exec(code, locals()). It's a good habit anyway to always pass a 
namespace to exec().

--
nosy: +amaury.forgeotdarc
resolution:  - invalid
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2011-12-09 Thread Stephan R.A. Deibel

Stephan R.A. Deibel sdei...@wingware.com added the comment:

Ah, thanks, there it is... I thought this must be dealt with somewhere but 
couldn't find it.  Maybe should add something to the 'exec' statement docs 
http://docs.python.org/py3k/library/functions.html#exec to reference this (from 
a usability-of-docs standpoint).

BTW, my code already sends the namespaces to exec (from current stack frame; 
it's part of a debugger) and probably would break other cases to alter this.

Well, anyway, sorry for the invalid bug report...

--
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13557] exec of list comprehension fails on NameError

2011-12-08 Thread Stephan R.A. Deibel

New submission from Stephan R.A. Deibel sdei...@wingware.com:

Calling exec() on code that includes a list comprehension that references a 
defined local variable x fails incorrectly on NameError: global name 'x' not 
defined.

--
files: execlistcomp.py
messages: 149050
nosy: sdeibel
priority: normal
severity: normal
status: open
title: exec of list comprehension fails on NameError
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file23883/execlistcomp.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13557
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com