fix python2.7 compatibility (e.g. for SSL sockets like OpenSSL.SSL.Connection)