BUG: Conversions between string <-> int were incorrectly releasing the GIL

I copied this fix from a patch I made
two years ago, which is in master:
https://github.com/numpy/numpy/commit/e39a70cffdd40ed2868a574803bd9535289d528d