mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-130660: Restore sys.ps1 and sys.ps2 after code.interact (#130661)
This commit is contained in:
parent
54965f3fb2
commit
fdcbc29f26
3 changed files with 45 additions and 5 deletions
13
Lib/code.py
13
Lib/code.py
|
@ -219,12 +219,17 @@ class InteractiveConsole(InteractiveInterpreter):
|
|||
"""
|
||||
try:
|
||||
sys.ps1
|
||||
delete_ps1_after = False
|
||||
except AttributeError:
|
||||
sys.ps1 = ">>> "
|
||||
delete_ps1_after = True
|
||||
try:
|
||||
sys.ps2
|
||||
_ps2 = sys.ps2
|
||||
delete_ps2_after = False
|
||||
except AttributeError:
|
||||
sys.ps2 = "... "
|
||||
delete_ps2_after = True
|
||||
|
||||
cprt = 'Type "help", "copyright", "credits" or "license" for more information.'
|
||||
if banner is None:
|
||||
self.write("Python %s on %s\n%s\n(%s)\n" %
|
||||
|
@ -287,6 +292,12 @@ class InteractiveConsole(InteractiveInterpreter):
|
|||
if _quit is not None:
|
||||
builtins.quit = _quit
|
||||
|
||||
if delete_ps1_after:
|
||||
del sys.ps1
|
||||
|
||||
if delete_ps2_after:
|
||||
del sys.ps2
|
||||
|
||||
if exitmsg is None:
|
||||
self.write('now exiting %s...\n' % self.__class__.__name__)
|
||||
elif exitmsg != '':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue