Fix "'NoneType' object has no attribute 'getsockopt'" for Python 3.3