[issue5945] PyMapping_Check returns 1 for lists

Antoine Pitrou report at bugs.python.org
Thu Jan 6 08:52:10 CET 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

Actually, making PyMapping_Check() more robust produces a test failure in test_builtin, because of the following code:

        # Verify locals stores (used by list comps)
        eval('[locals() for i in (2,3)]', g, d)
        eval('[locals() for i in (2,3)]', g, collections.UserDict())

        class SpreadSheet:
            "Sample application showing nested, calculated lookups."
            _cells = {}
            def __setitem__(self, key, formula):
                self._cells[key] = formula
            def __getitem__(self, key):
                return eval(self._cells[key], globals(), self)

        ss = SpreadSheet()
        ss['a1'] = '5'
        ss['a2'] = 'a1*6'
        ss['a3'] = 'a2*7'
        self.assertEqual(ss['a3'], 210)


Should I fix the example to include a keys() method?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5945>
_______________________________________


More information about the Python-bugs-list mailing list