Skip to content

Commit 1ab2939

Browse files
Use a bool to indicate whether we need to delete ps1/ps2
1 parent a23db4e commit 1ab2939

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Lib/code.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,18 @@ def interact(self, banner=None, exitmsg=None):
218218
219219
"""
220220
try:
221-
_ps1 = sys.ps1
221+
sys.ps1
222+
delete_ps1_after = False
222223
except AttributeError:
223-
_ps1 = None
224224
sys.ps1 = ">>> "
225+
delete_ps1_after = True
225226
try:
226227
_ps2 = sys.ps2
228+
delete_ps2_after = False
227229
except AttributeError:
228-
_ps2 = None
229230
sys.ps2 = "... "
231+
delete_ps2_after = True
232+
230233
cprt = 'Type "help", "copyright", "credits" or "license" for more information.'
231234
if banner is None:
232235
self.write("Python %s on %s\n%s\n(%s)\n" %
@@ -289,10 +292,10 @@ def interact(self, banner=None, exitmsg=None):
289292
if _quit is not None:
290293
builtins.quit = _quit
291294

292-
if _ps1 is None:
295+
if delete_ps1_after:
293296
del sys.ps1
294297

295-
if _ps2 is None:
298+
if delete_ps2_after:
296299
del sys.ps2
297300

298301
if exitmsg is None:

0 commit comments

Comments
 (0)