##// END OF EJS Templates
Support relative import in "%run -d -m"
Takafumi Arakaki -
Show More
@@ -543,25 +543,27 b' python-profiler package from non-free.""")'
543 543 # every single object ever created.
544 544 sys.modules[main_mod_name] = main_mod
545 545
546 try:
547 stats = None
548 with self.shell.readline_no_record:
549 if 'p' in opts:
546 if 'p' in opts or 'd' in opts:
550 547 if 'm' in opts:
551 548 code = 'run_module(modulename, prog_ns)'
552 prun_ns = {
549 code_ns = {
553 550 'run_module': self.shell.safe_run_module,
554 551 'prog_ns': prog_ns,
555 552 'modulename': modulename,
556 553 }
557 554 else:
558 555 code = 'execfile(filename, prog_ns)'
559 prun_ns = {
556 code_ns = {
560 557 'execfile': self.shell.safe_execfile,
561 558 'prog_ns': prog_ns,
562 559 'filename': get_py_filename(filename),
563 560 }
564 stats = self.prun('', code, False, opts, namespace=prun_ns)
561
562 try:
563 stats = None
564 with self.shell.readline_no_record:
565 if 'p' in opts:
566 stats = self.prun('', code, False, opts, namespace=code_ns)
565 567 else:
566 568 if 'd' in opts:
567 569 deb = debugger.Pdb(self.shell.colors)
@@ -596,11 +598,10 b' python-profiler package from non-free.""")'
596 598 # Start file run
597 599 print "NOTE: Enter 'c' at the",
598 600 print "%s prompt to start your script." % deb.prompt
599 ns = {'execfile': py3compat.execfile, 'prog_ns': prog_ns}
600 601 try:
601 602 #save filename so it can be used by methods on the deb object
602 603 deb._exec_filename = filename
603 deb.run('execfile("%s", prog_ns)' % filename, ns)
604 deb.run(code, code_ns)
604 605
605 606 except:
606 607 etype, value, tb = sys.exc_info()
General Comments 0
You need to be logged in to leave comments. Login now