Mailing List Archive

[6849] cherokee/trunk/qa/util.py: Workarounds Python's BUG #1515.
Revision: 6849
http://svn.cherokee-project.com/changeset/6849
Author: alo
Date: 2011-09-15 00:19:27 +0200 (Thu, 15 Sep 2011)
Log Message:
-----------
Workarounds Python's BUG #1515.

Modified Paths:
--------------
cherokee/trunk/qa/util.py

Modified: cherokee/trunk/qa/util.py
===================================================================
--- cherokee/trunk/qa/util.py 2011-09-14 19:29:48 UTC (rev 6848)
+++ cherokee/trunk/qa/util.py 2011-09-14 22:19:27 UTC (rev 6849)
@@ -296,3 +296,16 @@

out += '0\r\n'
return out
+
+
+# Workarounds Python's BUG #1515:
+# "deepcopy doesn't copy instance methods"
+#
+# http://bugs.python.org/issue1515
+#
+import copy
+import types
+
+def _deepcopy_method(x, memo):
+ return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class)
+copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method