MAINT: Get rid of a Python 3 resource warning.
Merge pull request #3815 from charris/backport-1.7-resourcewarning-fix

Backport 1.7 resourcewarning fix