Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

init.sage no longer used in notebook #251

Closed
kcrisman opened this issue Oct 24, 2014 · 5 comments
Closed

init.sage no longer used in notebook #251

kcrisman opened this issue Oct 24, 2014 · 5 comments
Labels

Comments

@kcrisman
Copy link
Member

See http://trac.sagemath.org/ticket/15308. This is presumably related to #169 as well, though perhaps is different.

@kcrisman
Copy link
Member Author

kcrisman commented Dec 3, 2014

Okay, given

try:
    attach(os.path.join(os.environ['DOT_SAGE'], 'init.sage'))
except (KeyError, IOError):
    pass

in sagenb/sagenb/notebook/worksheet.py, I think this is definitely the same as #169, though conceivably there is something even worse involved.

@kcrisman
Copy link
Member Author

kcrisman commented Dec 3, 2014

Hmm, but maybe it can be fixed by NOT lazy loading (as @jhpalmieri points out in http://trac.sagemath.org/ticket/15308) while still not fixing the overall attach issue.

@kcrisman
Copy link
Member Author

kcrisman commented Dec 3, 2014

Okay, here is something that fixes it. Feedback appreciated!

try:
    from sage.misc.preparser import load
    load(os.path.join(os.environ['DOT_SAGE'], 'init.sage'), globals(),attach=True)

although the attach=True is superfluous for now, because this does not fix #169.


It's really mysterious to me why this works, though, or rather why this is necessary, because from what I can tell, this is exactly the same code that should be in use in the load function from the attach call here. From messing around with this, I think that somehow the globals are clobbered beforehand, which gives a NameError for pretty much anything you could put into init.sage, which is not caught by the current try/except. But it also is not printed anywhere or outputted, because it's inside of S.execute(cmd), so it's very annoying to debug.

@kcrisman
Copy link
Member Author

kcrisman commented Dec 3, 2014

See #267

@kcrisman
Copy link
Member Author

Closed by #267.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant