[issue41216] eval don't load local variable in dict and list comprehensions.

2020-07-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

Agreed that this is a duplicate, so I'm closing it.

--
nosy: +eric.smith
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> eval() function in List Comprehension doesn't work

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41216] eval don't load local variable in dict and list comprehensions.

2020-07-05 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This seems to be a duplicate of issue5242, issue36300

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41216] eval don't load local variable in dict and list comprehensions.

2020-07-05 Thread Andrej Klychin


New submission from Andrej Klychin :

I'm not sure is it a bug or a fecature of comprehensions or eval, but 
intuitively it seems like it should work.

def foo(baz):
return eval("[baz for _ in range(10)]")

foo(3)
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in foo
  File "", line 1, in 
  File "", line 1, in 
NameError: name 'baz' is not defined

def bar(baz):
return eval("{i: baz for i in range(10)}")

bar(3)
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in bar
  File "", line 1, in 
  File "", line 1, in 
NameError: name 'baz' is not defined

--
components: Interpreter Core
messages: 373054
nosy: Andy_kl
priority: normal
severity: normal
status: open
title: eval don't load local variable in dict and list comprehensions.
type: behavior
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com