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/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4