Issue1619040

classification
Title: dict.fromkeys() should take iterable
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, kzuberi, leouserz
Priority: normal Keywords:

Created on 2006-12-19.20:43:58 by kzuberi, last changed 2007-02-20.08:03:56 by cgroves.

Messages
msg1375 (view) Author: Khalid Zuberi (kzuberi) Date: 2006-12-19.20:43:58
Christian Junker reports on jython-users:

"""
It seems like the fromkeys method of the dict class is not correctly
implemented in Jython 2.2a1:

>>> dict.fromkeys(['k1', 'k2'])
Traceback (innermost last):
 File "<console>", line 1, in ?
TypeError: descriptor 'fromkeys' requires 'dict' object but received a 'list'

It should require an iterable, not a dict as first argument.
"""

Note dict.fromkeys() was added to cpython in 2.3, but we are implementing it in 2.2 (as we do with a few other 2.3 features). 

- kz
msg1376 (view) Author: Deleted User leouserz (leouserz) Date: 2006-12-20.17:33:12
this appears to be happening because fromkeys is implemented as a method, while in python it is a classmethod.  By removing the PyMethodDescr and changing the implementing methods to static I was able to get the code to work.  The code as is works, if it is used with a dict instance.

leouser
msg1377 (view) Author: Charlie Groves (cgroves) Date: 2007-02-20.08:03:56
fixed in r3111 and 3112
History
Date User Action Args
2006-12-19 20:43:58kzubericreate