attach is broken
Closed this issue · 9 comments
Automatic reloading of attached files is broken on Sage-5.10.rc2. For example, start with a file containing "x=1". Then, in the notebook:
attach('/tmp/t.py')
x
works as intended. Now change the file to "x=2". All subsequent evaluations yield
Traceback (most recent call last):
File "", line 1, in
File "sage_input_5.py", line 10, in
exec compile(u'open("code.py","w").write("# -- coding: utf-8 --\n" + support.preparse_worksheet_cell(base64.b64decode("eA=="),globals())+"\n"); execfile(os.path.abspath("_code.py"))
File "", line 1, in
File "/tmp/tmpdG1Jqn/_code_.py", line 2
"/tmp/t.py"
^
IndentationError: unexpected indent
Ideally, this would be fixed in a way compatible with http://trac.sagemath.org/14523
This reportedly worked in some sage-5.x version
https://groups.google.com/d/msg/sage-devel/gHlK7zmgcAg/mREDSLLeI7wJ
I suspect it might have been earlier than 5.4. The flask notebook was
introduced in 5.4 and quite a few things regressed, even though it was
tested for months.
On Wed, Jun 26, 2013 at 12:07 PM, vbraun notifications@github.com wrote:
This reportedly worked in some sage-5.x version
https://groups.google.com/d/msg/sage-devel/gHlK7zmgcAg/mREDSLLeI7wJ
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/169#issuecomment-20026120
.
Given the current state of the notebook we should just remove the attach functionality in the notebook. Can be re-added to the new notebook when it is out.
So if we don't find a fix, should we make 'attach' just work like 'load', along with a warning that this is what it's doing?
Meanwhile, not only does it do automatic reloading, it just doesn't work: if I attach a file containing
print 3
b=4
then 3 gets printed, but if I evaluate b, I get a message saying that it is not defined. If I load the file instead, then b is defined.
I would prefer to just disable it, or maybe print an error message telling the user to use load instead.
Interestingly, I don't get any errors, just that it doesn't redo stuff when I change a file - whether from DATA or on the computer's filesystem. I am changing some doc related to this, anyway, which should help a tiny bit too - see 48bd7e7 .
I strongly suspect that this is related to lazy import, as pointed out in http://trac.sagemath.org/ticket/15308#comment:3 - at any rate, I'll be trying this out to see. Edit: or maybe not, still seems to be broken in earlier versions - I can't get it to work in 5.2, though the error is quite different, a recursion depth issue.
Interestingly, anything that requires preparsing seems to be bad now.
Using sage.misc.attached_files.attached_files() shows that attaching files does indeed happen; it is just not preparsed or something - indeed, .py files "work". However, I can confirm that things don't seem to stay defined.