Ticket #3560: sage-3560.patch

File sage-3560.patch, 1.5 KB (added by was, 14 years ago)
  • sage/server/notebook/gnutls_socket_ssl.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1215332847 25200
    # Node ID 048604f582924edf735e67c3b9cf86e239d7a40a
    # Parent  f7de82dc57a581a6bbc71519517e273566326574
    trac #3560 -- optimize import of gnutls_socket_ssl.py
        -- make it import gnutls.connection and gnutls.errors only when needed.
    
    diff -r f7de82dc57a5 -r 048604f58292 sage/server/notebook/gnutls_socket_ssl.py
    a b import socket 
    11import socket
    2 import gnutls
    3 import gnutls.connection
    4 import gnutls.errors
    52
    63class GnuTLSSocketSSL:
    74    """
    class GnuTLSSocketSSL: 
    118    socket.ssl MUST be set before urllib is imported.
    129    """
    1310    def __init__(self, sock, key_file=None, cert_file=None):
     11        import gnutls.connection
    1412        self.creds = gnutls.connection.X509Credentials()
    1513        self.session = gnutls.connection.ClientSession(sock, self.creds)
    1614        self.session.handshake()
    class GnuTLSSocketSSL: 
    2119    write = send
    2220   
    2321    def recv(self, *args, **kwds):
     22        import gnutls.errors
    2423        try:
    2524            s = self.session.recv(*args, **kwds)
    2625        except gnutls.errors.GNUTLSError:
    def require_SSL(): 
    3938    If ssl does not already exist in the socket module, supply our gnutls
    4039    version.
    4140    """
    42     if not hasattr(socket, "ssl"):
     41    if True or not hasattr(socket, "ssl"):
    4342        socket.ssl = GnuTLSSocketSSL