This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author anselm.kruis
Recipients Arfrever, anselm.kruis, rhettinger, schmir
Date 2013-05-22.11:36:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1369222609.14.0.0438555613185.issue18015@psf.upfronthosting.co.za>
In-reply-to
Content
I created a small *.pth to monkey patch collections.py until 2.7.6 gets released. Maybe this is useful for someone else. Therefore I attach it here.

The pth file runs the following code during Python startup:

import collections
def _fix_issue_18015(collections):
    try:
        template = collections._class_template
    except AttributeError:
        # prior to 2.7.4 _class_template didn't exists
        return
    if not isinstance(template, basestring):
        return  # strange
    if "__dict__" in template or "__getstate__" in template:
        return  # already patched
    lines = template.splitlines()
    indent = -1
    for i,l in enumerate(lines):
        if indent < 0:
            indent = l.find('def _asdict')
            continue
        if l.startswith(' '*indent + 'def '):
            lines.insert(i, ' '*indent + 'def __getstate__(self): pass')
            lines.insert(i, ' '*indent + '__dict__ = _property(_asdict)')
            break
    collections._class_template = '''\n'''.join(lines)
_fix_issue_18015(collections)
History
Date User Action Args
2013-05-22 11:36:49anselm.kruissetrecipients: + anselm.kruis, rhettinger, schmir, Arfrever
2013-05-22 11:36:49anselm.kruissetmessageid: <1369222609.14.0.0438555613185.issue18015@psf.upfronthosting.co.za>
2013-05-22 11:36:49anselm.kruislinkissue18015 messages
2013-05-22 11:36:48anselm.kruiscreate