summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/reference/c-api/array.rst11
-rw-r--r--doc/source/release/1.7.0-notes.rst2
-rw-r--r--numpy/core/src/multiarray/arrayobject.c16
3 files changed, 20 insertions, 9 deletions
diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst
index fb8acffe6..d2e873802 100644
--- a/doc/source/reference/c-api/array.rst
+++ b/doc/source/reference/c-api/array.rst
@@ -1623,6 +1623,17 @@ For all of these macros *arr* must be an instance of a (subclass of)
calculations in NumPy that rely on the state of these flags do not
repeat the calculation to update them.
+.. c:function:: int PyArray_FailUnlessWriteable(PyArrayObject *obj, const char *name)
+
+ This function does nothing and returns 0 if *obj* is writeable.
+ It raises an exception and returns -1 if *obj* is not writeable.
+ It may also do other house-keeping, such as issuing warnings on
+ arrays which are transitioning to become views. Always call this
+ function at some point before writing to an array.
+
+ *name* is a name for the array, used to give better error messages.
+ It can be something like "assignment destination", "output array",
+ or even just "array".
Array method alternative API
----------------------------
diff --git a/doc/source/release/1.7.0-notes.rst b/doc/source/release/1.7.0-notes.rst
index f111f80dc..40a6f550b 100644
--- a/doc/source/release/1.7.0-notes.rst
+++ b/doc/source/release/1.7.0-notes.rst
@@ -162,7 +162,7 @@ Added experimental support for the AArch64 architecture.
C API
-----
-New function ``PyArray_RequireWriteable`` provides a consistent interface
+New function ``PyArray_FailUnlessWriteable`` provides a consistent interface
for checking array writeability -- any C code which works with arrays whose
WRITEABLE flag is not known to be True a priori, should make sure to call
this function before writing.
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c
index 77961a8d3..3f080d902 100644
--- a/numpy/core/src/multiarray/arrayobject.c
+++ b/numpy/core/src/multiarray/arrayobject.c
@@ -622,15 +622,15 @@ array_might_be_written(PyArrayObject *obj)
/*NUMPY_API
*
- * This function does nothing if obj is writeable, and raises an exception
- * (and returns -1) if obj is not writeable. It may also do other
- * house-keeping, such as issuing warnings on arrays which are transitioning
- * to become views. Always call this function at some point before writing to
- * an array.
+ * This function does nothing and returns 0 if *obj* is writeable.
+ * It raises an exception and returns -1 if *obj* is not writeable.
+ * It may also do other house-keeping, such as issuing warnings on
+ * arrays which are transitioning to become views. Always call this
+ * function at some point before writing to an array.
*
- * 'name' is a name for the array, used to give better error
- * messages. Something like "assignment destination", "output array", or even
- * just "array".
+ * *name* is a name for the array, used to give better error messages.
+ * It can be something like "assignment destination", "output array",
+ * or even just "array".
*/
NPY_NO_EXPORT int
PyArray_FailUnlessWriteable(PyArrayObject *obj, const char *name)