[pypy-commit] pypy issue2446: fix missing __doc__ attribute properly (arigato)

mattip pypy.commits at gmail.com
Tue Dec 6 17:00:09 EST 2016


Author: Matti Picus <matti.picus at gmail.com>
Branch: issue2446
Changeset: r88918:5432199e0bc7
Date: 2016-12-06 20:51 +0200
http://bitbucket.org/pypy/pypy/changeset/5432199e0bc7/

Log:	fix missing __doc__ attribute properly (arigato)

diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -77,11 +77,6 @@
                             "from a PyObject",
                             w_type)
             raise
-        # XXX Assign some attributes of the w_type to the w_obj,
-        #     i.e. w_type.w_doc => w_obj.__doc__
-        #     are there more?
-        if w_type.w_doc:
-            space.setattr(w_obj, space.wrap('__doc__'), w_type.w_doc)
         track_reference(space, obj, w_obj)
         return w_obj
 
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -327,6 +327,8 @@
         w_obj = W_PyCWrapperObject(space, pto, method_name, wrapper_func,
                 wrapper_func_kwds, doc, func_voidp, offset=offset)
         dict_w[method_name] = space.wrap(w_obj)
+    if pto.c_tp_doc:
+        dict_w['__doc__'] = space.newbytes(rffi.charp2str(pto.c_tp_doc))
     if pto.c_tp_new:
         add_tp_new_wrapper(space, dict_w, pto)
 


More information about the pypy-commit mailing list