Ticket #470 (closed defect: fixed)
In Py>=2.6, kwargs can be general mappings
| Reported by: | robertwb | Owned by: | scoder |
|---|---|---|---|
| Priority: | major | Milestone: | 0.12.1 |
| Component: | Code Generation | Keywords: | |
| Cc: |
Description
See http://www.mail-archive.com/cython-dev@codespeak.net/msg08051.html and http://bugs.python.org/issue1686487
While testing type inference in mpi4py, I noticed that code like the
one below is failing in the last line. It seems that in Py>=2.6,
Python makes a coercion on "kw" and builds an actual dict instance
before calling.
class Foo:
def view(self, **kw):
print (kw)
for k in kw.keys():
print (k)
Foo().view(a=0, b=1, c=2)
class MyDict(object):
def __getitem__(self, k):
assert k == 'a'
return 7
def keys(self):
return ['a']
Foo().view(**MyDict()) # <-- Here is the issue
Change History
Note: See
TracTickets for help on using
tickets.
