Use conditional expression rather than and-or combination

* Introduced in Python 2.5
Simplify exception catching

* EnvironmentError covers both IOError and os.error since Python 1.5.2
* socket.error inherits IOError since Python 2.6 and Python 3
Avoid implicit exception argument unpacking

* Exceptions aren’t normally iterable in Python 3
* Use dedicated attributes of EnvironmentError()

Inspired using “2to3”.