Ticket #3685 (new defect)

Opened 6 months ago

Last modified 3 months ago

[with patch; needs work] make damned sure that "import sage.all" doesn't import ipython

Reported by: was Assigned to: cwitty
Priority: blocker Milestone: sage-3.4
Component: misc Keywords:
Cc:

Description

Make sure that doing this does not import ipython:

teragon-2:~ was$ sage -python
Python 2.5.2 (r252:60911, Jul 10 2008, 00:31:06) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sage.all

Attachments

sage-3685.patch (10.0 kB) - added by was on 07/20/2008 08:49:35 AM.

Change History

07/20/2008 07:52:51 AM changed by was

Here is how Ondrej Certik verifies that sage.all was importing ipython in sage-3.0.5:

I don't want to have anything in common with ipython, but sage invokes
it on import sage.all, as can be checked easily:

ondra@fuji:~/ext/sage$ . local/bin/sage-env
ondra@fuji:~/ext/sage$ python
Python 2.5.2 (r252:60911, Jul 11 2008, 05:28:36)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sage.all
>>>

Then apply this patch:

--- /tmp/genutils.py    2008-07-20 16:33:15.000000000 +0200
+++ local/lib/python2.5/site-packages/IPython/genutils.py       2008-07-20
16:33:26.553433732 +0200
@@ -54,6 +54,7 @@
        if not hasattr(stream,'write') or not hasattr(stream,'flush'):
            stream = fallback
        self.stream = stream
+        stop
        self._swrite = stream.write
        self.flush = stream.flush



and:

ondra@fuji:~/ext/sage$ python
Python 2.5.2 (r252:60911, Jul 11 2008, 05:28:36)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sage.all
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/sage/all.py",
line 58, in <module>
   from sage.misc.all       import *         # takes a while
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/sage/misc/all.py",
line 15, in <module>
   from sage_timeit_class import timeit
 File "sage_timeit_class.pyx", line 3, in sage.misc.sage_timeit_class
(sage/misc/sage_timeit_class.c:485)
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/sage/misc/sage_timeit.py",
line 12, in <module>
   import timeit as timeit_, time, math, preparser, interpreter
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/sage/misc/interpreter.py",
line 108, in <module>
   from IPython.iplib import InteractiveShell
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/IPython/__init__.py",
line 57, in <module>
   __import__(name,glob,loc,[])
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/IPython/ipstruct.py",
line 22, in <module>
   from IPython.genutils import list2dict2
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/IPython/genutils.py",
line 95, in <module>
   Term = IOTerm()
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/IPython/genutils.py",
line 90, in __init__
   self.cin  = IOStream(cin,sys.stdin)
 File "/home/ondra/ext/sage/local/lib/python2.5/site-packages/IPython/genutils.py",
line 57, in __init__
   stop
NameError: global name 'stop' is not defined

07/20/2008 08:49:05 AM changed by was

  • summary changed from make damned sure that "import sage.all" doesn't import ipython to [with patch; needs review] make damned sure that "import sage.all" doesn't import ipython.
  • milestone changed from sage-3.0.6 to sage-3.1.

I think this shouldn't go into 3.0.6 since it could introduce bugs, as it touches several files. That said, it's a smallish patch I made in 30 minutes. So it's not crazy complicated. It's just dangerous.

07/20/2008 08:49:35 AM changed by was

  • attachment sage-3685.patch added.

08/04/2008 02:01:54 AM changed by mhansen

  • summary changed from [with patch; needs review] make damned sure that "import sage.all" doesn't import ipython to [with patch; needs work] make damned sure that "import sage.all" doesn't import ipython.

This patch causes some problems on my machine.

1) Sage segfaults at exit.

2) When doing sage -t, I get the following problem for every file:

sage -t  devel/sage-combinat/sage/combinat/root_system/all.pyTraceback (most recent call last):
  File "/opt/sage/tmp/.doctest_all.py", line 2, in <module>
    from sage.all_cmdline import *; 
  File "/opt/sage/local/lib/python2.5/site-packages/sage/all_cmdline.py", line 14, in <module>
    from sage.all import *
  File "/opt/sage/local/lib/python2.5/site-packages/sage/all.py", line 72, in <module>
    from sage.rings.all      import *
  File "/opt/sage/local/lib/python2.5/site-packages/sage/rings/all.py", line 94, in <module>
    from qqbar import (AlgebraicRealField, is_AlgebraicRealField, AA,
  File "/opt/sage/local/lib/python2.5/site-packages/sage/rings/qqbar.py", line 1163, in <module>
    QQxy = QQ['x', 'y']
  File "ring.pyx", line 146, in sage.rings.ring.Ring.__getitem__ (sage/rings/ring.c:1851)
  File "/opt/sage/local/lib/python2.5/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 303, in PolynomialRing
    R = _multi_variate(base_ring, names, n, sparse, order)        
  File "/opt/sage/local/lib/python2.5/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 409, in _multi_variate
    from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomialRing_libsingular

08/13/2008 12:54:15 AM changed by was

Mike said:

1) Sage segfaults at exit. 2) When doing sage -t, I get the following problem for every file:

Mike, (1) what is your system? (2) Can you do "sage -ba" and try again?

-- William

10/23/2008 02:37:34 PM changed by anakha

I just tried it out and got none of the problems described above.

'import sage.all' doesn't import IPython as desired. I'm not putting up a positive review because of the problems described above, but I would be nice to have feedback on this

I'm on OS X 10.5 with this patch applied against 3.1.4.