[Python-Dev] Python2.5 _sre deepcopy regression?
Andrew McNamara
andrewm at object-craft.com.au
Tue Nov 4 02:32:28 CET 2008
<prod> I posted this week ago, but haven't seen any comments. Issue
416670 is probably the most relevent ticket.
The buggy changeset I mention, 38430 on the release24-maint branch is
one that had been forward and back-ported for a while. I haven't found
the motivation for that change, but it hasn't been applied to any version
of Python later than 2.4.
>In version of Python prior to 2.5, it would appear that deepcopying
>compiled regular expressions worked by accident:
>
>2.4:
>
> >>> copy.deepcopy(re.compile(''))
> <_sre.SRE_Pattern object at 0xb7d53ef0>
>
>2.5:
>
> >>> copy.deepcopy(re.compile(''))
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/python2.5/copy.py", line 173, in deepcopy
> y = copier(memo)
> TypeError: cannot deepcopy this pattern object
>
>I say "by accident", since the SRE_Pattern object in 2.4 has
>a __deepcopy__ method which raises the "cannot deepcopy this pattern
>object" TypeError, however this method isn't found by copy.deepcopy()
>in 2.4, and copy.deepcopy() falls back to using the pickle logic.
>
>The _sre source has #ifdef-out support for __deepcopy__, issue 416670
>has the gory details:
>
> http://bugs.python.org/issue416670
>
>Changeset 38430 on the release24-maint branch introduced the changes
>that stopped SRE_Pattern.__deepcopy__ being found. r38430 was a patch
>forward ported from 2.3, but never ported to the trunk (probably a good
>thing, too).
>
>Thoughts?
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
More information about the Python-Dev
mailing list