summaryrefslogtreecommitdiff
path: root/numpy/core/function_base.py
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2019-07-09 15:26:08 -0500
committerEric Wieser <wieser.eric@gmail.com>2019-07-09 20:01:20 -0700
commit45c4a8dc09ecaff6352a2e17cb242f7ae5ca11a9 (patch)
tree42906076bde2c89088e84e9a45af1b247ec6592c /numpy/core/function_base.py
parentf730ea85c441e2af73a3f1d19f86412240bc106d (diff)
downloadnumpy-45c4a8dc09ecaff6352a2e17cb242f7ae5ca11a9.tar.gz
DOC: point out the shortcomings of add_newdocs
Diffstat (limited to 'numpy/core/function_base.py')
-rw-r--r--numpy/core/function_base.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py
index 661b744b1..a316e072f 100644
--- a/numpy/core/function_base.py
+++ b/numpy/core/function_base.py
@@ -467,6 +467,16 @@ def add_newdoc(place, obj, doc):
in new-style classes or built-in functions. Because this
routine never raises an error the caller must check manually
that the docstrings were changed.
+
+ Since this function grabs the ``char *`` from a c-level str object and puts
+ it into the ``tp_doc`` slot of the type of `obj`, it violates a number of
+ C-API best-practices, by:
+
+ - modifying a `PyTypeObject` after calling `PyType_Ready`
+ - calling `Py_INCREF` on the str and losing the reference, so the str
+ will never be released
+
+ If possible it should be avoided.
"""
new = getattr(__import__(place, globals(), {}, [obj]), obj)
if isinstance(doc, str):