Avoid ResourceWarning on Python 3