Consolidate all array writeability checking in new PyArray_RequireWriteable

This is mostly a code cleanup, but it does have a user-visible effect
in that attempting to write to a unwriteable array now consistently
raises ValueError. (It used to randomly raise either ValueError or
RuntimeError.)

Passes numpy.test("full").
Funnel all assignments to PyArrayObject->base through a single point

This patch removes all direct assignments of non-NULL values to the
'base' field on PyArrayObjects. A new utility function was created to
set up UPDATEIFCOPY arrays, and all assignments to 'base' were
adjusted to use either PyArray_SetBaseObject or the new
PyArray_SetUpdateIfCopyBase.

One advantage of this is that it produces more consistent error
handling. This error handling revealed a bug in the nditer code,
which this patch does *not* yet fix.

The bug is that npyiter_new_temp_array sometimes (when dealing with
reversed axes) creates an array and then returns a view onto it. But,
npyiter_allocate_arrays assumes that the array returned by
npyiter_new_temp_array can have UPDATEIFCOPY set, which requires
reassigning its 'base' field. Previously, this meant that the
temporary array leaked. Now, it produces a ValueError.

This code path doesn't seem to actually be hit very often; only one of
the nditer tests fails because of the change. See
   numpy/core/tests/test_nditer.py:test_iter_array_cast_buggy
Add a test for ndarray.diagonal()

All 'expected' values were computed using numpy 1.5.1, so we can be
pretty sure that the recent rewrite didn't change any results.
Transition scheme for allowing PyArray_Diagonal to return a view

PyArray_Diagonal is changed to return a copy of the diagonal (as in
numpy 1.6 and earlier), but with a new (hidden) WARN_ON_WRITE flag
set. Writes to this array (or views thereof) will continue to work as
normal, but the first write will trigger a DeprecationWarning.

We also issue this warning if someone extracts a non-numpy writeable
view of the array (e.g., by accessing the Python-level .data
attribute). There are likely still places where the data buffer is
exposed that I've missed -- review welcome!

New known-fail test: eye() for maskna arrays was only implemented by
exploiting ndarray.diagonal's view-ness, so it is now unimplemented
again, and the corresponding test is marked known-fail.
Document the PyArray_Diagonal transition scheme.
Typo fix

Thanks to Travis for catching it.
Merge branch 'master' into clean-up-diagonal
Un-KNOWNFAIL the nditer test after merging Mark's fix from master
Fix a C90 compatibility error
Add a missing guard for Python versions <2.6
Clean up PyArray_Diagonal changes based on Chuck's feedback

- NPY_ARRAY_WARN_ON_WRITE flag definition is protected by #ifdef
  _MULTIARRAYMODULE, to make totally sure that we can recycle the flag
  bit later.
- Improve docs for PyArray_SetUpdateIfCopyBase.
- Make the deprecation warning for writes to the diagonal array
  somewhat more terse.
- Use DEPRECATE macro instead of calling PyErr_Warn/PyErr_WarnEx
  directly.
- Comment formatting fixed.
Don't assume ctypes is available, it's not true on Python 2.4
Fix diagonal-related warnings and tests on Python 3
Move internal NPY_ARRAY_WARN_ON_WRITE flag into an internal header.
Rename PyArray_RequireWriteable to PyArray_FailUnlessWriteable

Also clean up its API slightly so that the caller passes in a name
describing the array being checked which is used to generate an error
message, rather than writing an error message from scratch.
Merge branch 'master' into clean-up-diagonal