[Python-bugs-list] [Bug #115126] Over restricted type checking on eval() function
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 22 Sep 2000 12:42:45 -0700
Bug #115126, was updated on 2000-Sep-22 12:36
Here is a current snapshot of the bug.
Project: Python
Category: Core
Status: Open
Resolution: None
Bug Group: Feature Request
Priority: 5
Summary: Over restricted type checking on eval() function
Details: The built-in function eval() takes a string argument and a dictionary. The second argument should allow any instance which defines __getitem__ as opposed to just dictionaries.
The following example creates a type error:
eval, argument 2: expected dictionary, instance found
class SpreadSheet:
_cells = {}
def __setitem__( self, key, formula ):
self._cells[key] = formula
def __getitem__( self, key ):
return eval( self._cells[key], self )
ss = SpreadSheet()
ss['a1'] = '5'
ss['a2'] = 'a1*5'
ss['a2']
Follow-Ups:
Date: 2000-Sep-22 12:42
By: tim_one
Comment:
Changed Group to Feature Request. Should be added to PEP 42 (I'll do that if nobody beats me to it).
CPython requires a genuine dict now for speed. I believe JPython allows any mapping object.
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=115126&group_id=5470