Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
Fix issue with python2.5 missing ssl (no ssl support if package is no…
Browse files Browse the repository at this point in the history
…t installed)
  • Loading branch information
reingart committed Sep 10, 2011
1 parent 7110b44 commit f963525
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pg8000/protocol.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
__author__ = "Mathieu Fenniak" __author__ = "Mathieu Fenniak"


import socket import socket
import ssl as sslmodule try:
import ssl as sslmodule
except ImportError:
sslmodule = None
import select import select
import threading import threading
import struct import struct
Expand Down Expand Up @@ -945,8 +948,10 @@ def __init__(self, unix_sock=None, host=None, port=5432, socket_timeout=60, ssl=
self._send(SSLRequest()) self._send(SSLRequest())
self._flush() self._flush()
resp = self._sock.recv(1) resp = self._sock.recv(1)
if resp == 'S': if resp == 'S' and sslmodule is not None:
self._sock = sslmodule.wrap_socket(self._sock) self._sock = sslmodule.wrap_socket(self._sock)
elif sslmodule is None:
raise InterfaceError("SSL required but ssl module not available in this python installation")
else: else:
raise InterfaceError("server refuses SSL") raise InterfaceError("server refuses SSL")
finally: finally:
Expand Down

0 comments on commit f963525

Please sign in to comment.