Fix a segfault in `astropy.wcs._wcs`.

At a certain point in our test suite, the interpreter stops
being able to allocate even fairly small objects.  I haven't
gotten to the bottom of why that is, but this fix at least
prevents that case from becoming an out-and-out segfault.
Merge pull request #2665 from mdboom/wcs/fix-segfault

Fix a segfault in `astropy.wcs._wcs`.