PYTHON-436 Fix potential regression which wouldn't catch socket errors properly