mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
SF bug #1004669: Type returned from .keys() is not checked
This commit is contained in:
parent
61992efc4b
commit
2a7dedef9e
2 changed files with 14 additions and 0 deletions
|
@ -322,6 +322,15 @@ class BuiltinTest(unittest.TestCase):
|
|||
ss['a3'] = 'a2*7'
|
||||
self.assertEqual(ss['a3'], 210)
|
||||
|
||||
# Verify that dir() catches a non-list returned by eval
|
||||
# SF bug #1004669
|
||||
class C:
|
||||
def __getitem__(self, item):
|
||||
raise KeyError(item)
|
||||
def keys(self):
|
||||
return 'a'
|
||||
self.assertRaises(TypeError, eval, 'dir()', globals(), C())
|
||||
|
||||
# Done outside of the method test_z to get the correct scope
|
||||
z = 0
|
||||
f = open(TESTFN, 'w')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue