[ python-Bugs-1004669 ] Type returned from .keys() is not checked

SourceForge.net noreply at sourceforge.net
Fri Aug 6 20:49:24 CEST 2004


Bugs item #1004669, was opened at 2004-08-06 08:08
Message generated for change (Comment added) made by isandler
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1004669&group_id=5470

Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: ben handley (bhandley)
Assigned to: Nobody/Anonymous (nobody)
Summary: Type returned from .keys() is not checked

Initial Comment:
When passing a mapping object as the locals to eval, it
doesn't check that the return value of .keys() is a
tuple early enough, resulting in a SystemError:

>>> class C:
...     def __getitem__(self, item):
...         raise KeyError, item
...     def keys(self):
...         return 'a'
...
>>> c=C()
>>> print eval('dir()', globals(), c)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 0, in ?
SystemError: Objects/listobject.c:2110: bad argument to
internal function



----------------------------------------------------------------------

Comment By: Ilya Sandler (isandler)
Date: 2004-08-06 11:49

Message:
Logged In: YES 
user_id=971153

Why do you think the existing behaviour is wrong?

All Python type checking is done at run time
E.g.
>>> 12+"123"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unsupported operand types for +: 'int' and 'str'

How is your example different?

I would suggest to close the bug

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1004669&group_id=5470


More information about the Python-bugs-list mailing list