Bugs item #1730480, was opened at 2007-06-03 20:59
Message generated for change (Settings changed) made by blakeross
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1730480&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Blake Ross (blakeross)
Assigned to: Nobody/Anonymous (nobody)
Summary: dict init/update accesses internal items of dict derivative

Initial Comment:
>>> class MyDict(dict):
...     def keys(self): print "keys"
...     def __getitem__(self, n): print "__getitem__"
...
>>> myDict = MyDict(a=1, b=2)
>>> dict(myDict)
{'a': 1, 'b': 2}

PyDict_Merge accesses the items of the dict to be merged directly rather than 
going through the interface for any dict instance--even a dict derivative--by 
virtue of using PyDict_Check rather than PyDict_CheckExact. I believe the logic 
needs to be:

if type(d).__getitem__ is dict.__getitem__ and type(d).keys is dict.keys:
    ...okay to access items directly...
else:
    ...go through the methods...


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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1730480&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to