sage icon indicating copy to clipboard operation
sage copied to clipboard

`reset()` modifies `__name__`

Open user202729 opened this issue 5 months ago • 2 comments

Steps To Reproduce

as in the title.

sage: __name__
'__main__'
sage: reset()
sage: __name__
'sage.all_cmdline'

Expected Behavior

the last line doesn't modify __name__, or change it to "__main__"

Actual Behavior

Additional Information

No response

Environment

  • OS:
  • Sage Version:

Checklist

  • [x] I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • [x] I have read the documentation and troubleshoot guide

user202729 avatar Aug 02 '25 12:08 user202729

This problem is probably realted:

In x.sage, type:

print(__name__)

In sage 10.7, sage x.sage prints sage.all. But in sage 10.5, sage x.sage prints __main__.

maple3142 avatar Nov 10 '25 13:11 maple3142

In sage 10.7, sage x.sage prints sage.all. But in sage 10.5, sage x.sage prints __main__.

I came here to report this. This effectively breaks scripts that gatekeep execution by if __name__ == "__main__"

clanoftheducks avatar Nov 24 '25 15:11 clanoftheducks