Fix catch_warnings for Python 3