Robert Haschke <[email protected]> added the comment:
Looks like the list generator is considered as a new nested scope, which
prohibits access to local variables?
This basic expression, passing local symbols only, fails as well:
eval('[abc[i]*abc[i] for i in [0, 1, 2]]', {}, dict(abc=[1, 2, 3]))
while this one, passing dict as global symbols, works:
eval('[abc[i]*abc[i] for i in [0, 1, 2]]', dict(abc=[1, 2, 3]))
However, passing globals must be a real dict. So I cannot simply pass my custom
mapping to globals.
----------
title: python3 fails to use custom dict-like object as symbols in eval() ->
python3 fails to use custom mapping object as symbols in eval()
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41878>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com