#14066 closed defect (fixed)
FIx IPython 0.13 issues
Reported by: | jason | Owned by: | was |
---|---|---|---|
Priority: | blocker | Milestone: | sage-5.7 |
Component: | user interface | Keywords: | |
Cc: | vbraun | Merged in: | sage-5.7.rc0 |
Authors: | Jason Grout | Reviewers: | Volker Braun, Jeroen Demeyer |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
Can we keep this ticket open to track all the remaining IPython issues left over from #12719?
Still outstanding:
From Kannappan Sampath:
- I am unable to exit by typing "exit", but Ctrl+D however works!
- The following (from #12719)
jec@fermat%./sage ---------------------------------------------------------------------- | Sage Version 5.7.beta1, Release Date: 2013-01-26 | | Type "notebook()" for the browser-based notebook interface. | | Type "help()" for help. | ---------------------------------------------------------------------- ********************************************************************** * * * Warning: this is a prerelease version, and it may be unstable. * * * ********************************************************************** --------------------------------------------------------------------------- NameError Traceback (most recent call last) /home/jec/sage-5.7.beta1/local/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where) 176 else: 177 filename = fname --> 178 __builtin__.execfile(filename, *where) /home/jec/.sage/init.sage in <module>() ----> 1 load /home/jec/sage/ecdb.py NameError: name 'load' is not defined
apply:
Attachments (2)
Change History (25)
comment:1 Changed 9 years ago by
- Description modified (diff)
comment:2 Changed 9 years ago by
- Description modified (diff)
comment:3 Changed 9 years ago by
- Description modified (diff)
comment:4 Changed 9 years ago by
Regarding (3), loading a sage file (i.e., %runfile init.sage) certainly works with sage syntax like load. So the problem appears to be that the %runfile code isn't being used to run init.sage.
comment:5 Changed 9 years ago by
- Description modified (diff)
(2) is certainly not related to IPython.
comment:6 Changed 9 years ago by
- Component changed from PLEASE CHANGE to user interface
- Owner changed from tbd to was
comment:7 Changed 9 years ago by
- Description modified (diff)
- Priority changed from major to blocker
comment:8 Changed 9 years ago by
For (1): In devel/sage/sage/all.py, we find this code at the very top:
# Error message that matches the Sage/IPython defaults quit = "Use Ctrl-D (i.e. EOF), %Exit, or %Quit to exit without confirmation." exit = quit
Who put that there? Deleting those lines restores exit and quit to act just as expected.
comment:9 Changed 9 years ago by
It looks like William put it there in 2006, so apparently it is a leftover from the old system. I wonder how exit and quit worked before; clearly they didn't just print the string!
comment:10 Changed 9 years ago by
So issue (1) seems to have a solution. Here's an idea for (2):
-
sage/misc/sage_extension.py
diff --git a/sage/misc/sage_extension.py b/sage/misc/sage_extension.py
a b 453 453 """ 454 454 startup_file = os.environ.get('SAGE_STARTUP_FILE', '') 455 455 if os.path.exists(startup_file): 456 self.shell.run_cell('%%run %r'%startup_file) 456 with open(startup_file, 'r') as f: 457 self.shell.run_cell(f.read()) 457 458 458 459 def init_inspector(self): 459 460 # Ideally, these would just be methods of the Inspector class
(That is, call run_cell
on the contents of the init file, instead of calling run_cell(%%run ...)
on the init file itself.)
comment:11 Changed 9 years ago by
I don't know much about this IPython stuff, but it would be good to resolve these issues as this is the only remaining blocker for sage-5.7.
comment:12 Changed 9 years ago by
John, that fix seems reasonable. Looking at the IPython source, the default for the %run magic is to run using the python execfile function, so that explains why sage-specific things didn't work. run_cell should apply the sage-specific things.
But I would change the call to run_cell(f.read(), silent=True)
(and then check to make sure tracebacks still work; if not, then use run_cell(f.read(), store_history=False)
)
comment:13 Changed 9 years ago by
To be consistent with shell.runfile_ipy, I just use store_history=False...
Changed 9 years ago by
Changed 9 years ago by
comment:14 Changed 9 years ago by
- Description modified (diff)
- Status changed from new to needs_review
comment:15 follow-up: ↓ 17 Changed 9 years ago by
I've noticed that attach no longer works. It says it's been deprecated and to use %attach, but then this appears to have a bug.
If I have a file "test.py" which contains one line
print "hello"
then when I attach:
%attach 'test.py'
then it prints hello. But if I rewrite the line to:
print "hey"
and then hit enter on sage, it doesn't print anything.
comment:16 Changed 9 years ago by
I think that %attach
sort of works, maybe even mostly works, but printing does not. If my file contains the line a=3
:
sage: %attach test.py sage: a 3 sage: # now I edit test.py to say a=12.0 sage: a 12.0
Function definitions get updated just fine, but as you point out, print statements don't seem to work right. What else needs to be tested to know if print statements are the only issue?
Note that if I attach a file with print statements, then change it, then attach it again, the print statements appear twice. So I think the change is being detected, but the output isn't showing up when it should.
comment:17 in reply to: ↑ 15 Changed 9 years ago by
Replying to chrisjamesberg:
and then hit enter on sage, it doesn't print anything.
I don't quite understand what the problem is. Is it a problem that simply hitting ENTER doesn't reload the file, that the file is only reloaded before executing an actual command?
Because other than that, I find that %attach
works fine. So, I'm willing to give this positive_review.
comment:18 Changed 9 years ago by
Regarding attach, I suppose that is a difference between the old and new. In the old, the attach expressions were run after every enter press (i.e., before the prompt was displayed). Now they are run just before any code is executed. I guess the issue is that blank lines in some sense "don't count" because of a shortcut. Let me see if I can add an option for attached files to run there as well.
comment:19 Changed 9 years ago by
It's going to be a bit tricky to execute attached files on empty input (i.e., just pressing enter) because, by default, IPython ignores attempts to execute code on empty strings. Do we really need this?
comment:20 Changed 9 years ago by
I don't think its necessary. I'm sure it'll break somebody's workflow (http://xkcd.com/1172/) but there are better solutions to "reload when saved" that don't involve sending non-commands.
comment:21 Changed 9 years ago by
- Reviewers set to Volker Braun, Jeroen Demeyer
- Status changed from needs_review to positive_review
Since nobody complained I set this to positive review ;-)
comment:22 Changed 9 years ago by
- Merged in set to sage-5.7.rc0
- Resolution set to fixed
- Status changed from positive_review to closed
comment:23 Changed 9 years ago by
See #14144 for another one.
Another