@@ -2510,14 +2510,18 @@ def complete_shell(self, text, line, begidx, endidx):
25102510 return self .index_based_complete (text , line , begidx , endidx , index_dict , self .path_complete )
25112511
25122512 @staticmethod
2513- def _reset_sys () -> None :
2513+ def _reset_py_display () -> None :
25142514 """
2515- Resets the dynamic objects in the sys modules that the py and ipy consoles fight over
2516- This makes it so the py console doesn't end up looking like the ipy console in terms of
2517- prompt and exception text. That happens if a user runs py after being in an IPython console.
2515+ Resets the dynamic objects in the sys module that the py and ipy consoles fight over.
2516+ When a Python console starts it adopts certain display settings if they've already been set.
2517+ If an ipy console has previously been run, then py uses its settings and ends up looking
2518+ like an ipy console in terms of prompt and exception text. This method forces the Python
2519+ console to create its own display settings since they won't exist.
25182520
2521+ IPython does not have this problem since it always overwrites the display settings when it
2522+ is run. Therefore this method only needs to be called before creating a Python console.
25192523 """
2520- # Delete any prompts set by the interactive consoles
2524+ # Delete any prompts that have been set
25212525 attributes = ['ps1' , 'ps2' , 'ps3' ]
25222526 for cur_attr in attributes :
25232527 try :
@@ -2640,8 +2644,8 @@ def quit():
26402644 interp .runcode ("import readline" )
26412645 interp .runcode ("readline.set_completer(Completer(locals()).complete)" )
26422646
2643- # Set up sys for the console
2644- self ._reset_sys ()
2647+ # Set up sys module for the Python console
2648+ self ._reset_py_display ()
26452649 keepstate = Statekeeper (sys , ('stdin' , 'stdout' ))
26462650 sys .stdout = self .stdout
26472651 sys .stdin = self .stdin
@@ -2738,7 +2742,6 @@ def do_ipy(self, arg):
27382742 End with ``Ctrl-D`` (Unix) / ``Ctrl-Z`` (Windows), ``quit()``, '`exit()``.
27392743 """
27402744 from .pyscript_bridge import PyscriptBridge
2741- self ._reset_sys ()
27422745 bridge = PyscriptBridge (self )
27432746
27442747 if self .locals_in_py :
0 commit comments