Armin Rigo committed 5b2403f

issue1293 fixed: changing func_code must not change the docstring

Comments (0)

Files changed (2)


             raise operationerrfmt(space.w_ValueError,
                 "%s() requires a code object with %d free vars, not %d",
       , closure_len, len(code.co_freevars))
+        self.fget_func_doc(space)    # see test_issue1293
         self.code = code
     def fget_func_closure(self, space):


         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():