Ticket #12719: trac_12719-crash.patch

File trac_12719-crash.patch, 1.6 KB (added by mhansen, 9 years ago)
  • sage/misc/interpreter.py

    # HG changeset patch
    # User Mike Hansen <mhansen@gmail.com>
    # Date 1338236723 25200
    # Node ID fa529902ad09f5d3a1933630a524d2fda2e12761
    # Parent  547464f9c446ff36235fe813a49a8c8a04cb03fb
    #12719: Handle crashes importing the Sage library better
    
    diff --git a/sage/misc/interpreter.py b/sage/misc/interpreter.py
    a b  
    12581258            sage: app.shell
    12591259            <sage.misc.interpreter.SageInteractiveShell object at 0x...>
    12601260        """
     1261        import sys
    12611262        sys.path.insert(0, '')
    12621263
    12631264        # Overwrite the default Sage configuration with the user's.
     
    12921293        branch = branch_current_hg_notice(branch_current_hg())
    12931294        if branch and self.test_shell is False:
    12941295            print branch
     1296           
     1297        try:
     1298            self.shell.ex('from sage.all import Integer, RealNumber')
     1299        except Exception:
     1300            import traceback
     1301            print "Error importing the Sage library"
     1302            traceback.print_exc()
     1303            print
     1304            print "To debug this, you can run:"
     1305            print 'sage -ipython -i -c "import sage.all"'
     1306            print 'and then type "%debug" to enter the interactive debugger'
     1307            sys.exit(1)
    12951308
    1296         self.shell.ex('from sage.all import Integer, RealNumber')
    12971309        self.shell.push(dict(sage_prompt=sage_prompt))
    12981310
    12991311        if os.environ.get('SAGE_IMPORTALL', 'yes') != 'yes':
    13001312            return
     1313
    13011314        self.shell.ex('from sage.all_cmdline import *')
    13021315        startup_file = os.environ.get('SAGE_STARTUP_FILE', '')
    13031316