BUG: Make PyArray_PutTo respect writeable flag.

Cleanup of #5132.

Rebased for backport to 1.9.x.