Ticket #2346: 2346-early-ssl-import.patch

File 2346-early-ssl-import.patch, 2.1 KB (added by robertwb, 14 years ago)
  • sage/all.py

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1207458963 25200
    # Node ID db4fa0556c04f00d5b3fa97cc578011fee621672
    # Parent  6d666243f6660f80cd0330d8a7e4fce608aba5bf
    import gnutls SSL before anything else
    
    diff -r 6d666243f666 -r db4fa0556c04 sage/all.py
    a b if sys.version_info[:2] < (2, 5): 
    3737    sys.exit(1)
    3838
    3939   
     40###################################################################
     41
     42# We have to set this here so urllib, etc. can detect it.
     43import sage.server.notebook.gnutls_socket_ssl
     44sage.server.notebook.gnutls_socket_ssl.require_SSL()
     45
    4046###################################################################
    4147
    4248from random              import *
  • sage/server/notebook/gnutls_socket_ssl.py

    diff -r 6d666243f666 -r db4fa0556c04 sage/server/notebook/gnutls_socket_ssl.py
    a b class GnuTLSSocketSSL: 
    3434        self.session.shutdown()
    3535        self.session.close()
    3636       
     37def require_SSL():
     38    """
     39    If ssl does not already exist in the socket module, supply our gnutls
     40    version.
     41    """
     42    if not hasattr(socket, "ssl"):
     43        socket.ssl = GnuTLSSocketSSL
  • sage/server/notebook/notebook_object.py

    diff -r 6d666243f666 -r db4fa0556c04 sage/server/notebook/notebook_object.py
    a b def test_notebook(admin_passwd, director 
    171171        sage: nb.dispose()
    172172        """
    173173    import socket
    174     if not hasattr(socket, 'ssl'):
    175         import sage.server.notebook.gnutls_socket_ssl
    176         socket.ssl = sage.server.notebook.gnutls_socket_ssl.GnuTLSSocketSSL
    177         import urllib
    178         if not hasattr(urllib, 'open_https'):
    179             raise RuntimeError, "urllib imported before test_notebook called, can't be fixed now..."
    180174       
    181175    if directory is None:
    182176        directory = tmp_dir = tempfile.mkdtemp()