Show More
@@ -649,23 +649,24 b' python-profiler package from non-free.""")' | |||
|
649 | 649 | |
|
650 | 650 | sys.argv = [filename] + args # put in the proper filename |
|
651 | 651 | |
|
652 | if 'n' in opts: | |
|
653 | name = os.path.splitext(os.path.basename(filename))[0] | |
|
654 | else: | |
|
655 | name = '__main__' | |
|
656 | ||
|
652 | 657 | if 'i' in opts: |
|
653 | 658 | # Run in user's interactive namespace |
|
654 | 659 | prog_ns = self.shell.user_ns |
|
655 | 660 | __name__save = self.shell.user_ns['__name__'] |
|
656 |
prog_ns['__name__'] = |
|
|
661 | prog_ns['__name__'] = name | |
|
657 | 662 | main_mod = self.shell.user_module |
|
658 | ||
|
663 | ||
|
659 | 664 | # Since '%run foo' emulates 'python foo.py' at the cmd line, we must |
|
660 | 665 | # set the __file__ global in the script's namespace |
|
661 | 666 | # TK: Is this necessary in interactive mode? |
|
662 | 667 | prog_ns['__file__'] = filename |
|
663 | 668 | else: |
|
664 | 669 | # Run in a fresh, empty namespace |
|
665 | if 'n' in opts: | |
|
666 | name = os.path.splitext(os.path.basename(filename))[0] | |
|
667 | else: | |
|
668 | name = '__main__' | |
|
669 | 670 | |
|
670 | 671 | # The shell MUST hold a reference to prog_ns so after %run |
|
671 | 672 | # exits, the python deletion mechanism doesn't zero it out |
General Comments 0
You need to be logged in to leave comments.
Login now