BUG: fix potentially infinite recursion in VOID_nonzero. Fixes #3312.
TST: add a test for issue #3312
Merge pull request #3317 from ecatmur/maintenance/1.7.x

Backport #3313 to maintenance/1.7.x