[Python-Dev] Python 2.5.1c1 pickle problem (original) (raw)

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sun Apr 15 23:53:03 CEST 2007


Hi Raymond,

Thanks for the detailed explanation!

I'm not sure what your code was doing where the bugfix would cause breakage. If its getitem() override returned a meaningful value for each element in obj.keys(), then it should have worked fine. Of course, if it was raising an exception or triggering a side-effect, then one could argue that the bugfix was working as intended by allowing the subclasser to affect how the base class goes about its business.

It wasn't actually my own code, but that of a colleague. His getitem() override is below. It fails because getitem() is called with the wrong type of argument (plain int instead of a list of atoms). I'm not sure it presents a convincing use case. I would have used composition instead of inheritance in the same situation.

I don't feel competent to join the discussion about the changes in the pickling behavior, but I feel quite strongly that such a change should not be introduced in a bug-fix release.

Ralf

def getitem(self, atoms): LIST = [] for atom in atoms: attr = 'index' if hasattr(atom, 'unique_index'): attr = 'unique_index' LIST.append(getattr(atom, attr)) key1 = tuple(LIST) LIST.reverse()
key2 = tuple(LIST)

rc = None
try:
  rc =

dict.getitem(self, key1) except KeyError, e: pass try: rc = dict.getitem(self, key2) except KeyError, e: pass return rc


Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20070415/d4def50d/attachment.html



More information about the Python-Dev mailing list