Author: Armin Rigo <[email protected]>
Branch:
Changeset: r58202:5b2403f92a1e
Date: 2012-10-18 11:17 +0200
http://bitbucket.org/pypy/pypy/changeset/5b2403f92a1e/
Log: issue1293 fixed: changing func_code must not change the docstring
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -415,6 +415,7 @@
raise operationerrfmt(space.w_ValueError,
"%s() requires a code object with %d free vars, not %d",
self.name, closure_len, len(code.co_freevars))
+ self.fget_func_doc(space) # see test_issue1293
self.code = code
def fget_func_closure(self, space):
diff --git a/pypy/interpreter/test/test_function.py
b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -299,6 +299,12 @@
assert f.__doc__ == u"hi"
assert type(f.__doc__) is unicode
+ def test_issue1293(self):
+ def f1(): "doc f1"
+ def f2(): "doc f2"
+ f1.func_code = f2.func_code
+ assert f1.__doc__ == "doc f1"
+
def test_subclassing(self):
# cannot subclass 'function' or 'builtin_function'
def f():
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit