[PATCH v2 03/23] tests: Use python3 and python2 compatible socket exception type