Skip to content

Commit 34a49aa

Browse files
authored
bpo-38002: Use False/True for IDLE pyshell bools (GH-19203)
Change 0/1 assignments to 'executing', 'canceled', 'reading', 'endoffile'. These are not used outside of pyshell. Other bools already use False/True. Add comment about int needed for Windows call. Remove self.more, unused in idlelib and code.InteractiveInterpreter. The latter uses 'more' as a local.
1 parent 34b0598 commit 34a49aa

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

Lib/idlelib/pyshell.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
if sys.platform == 'win32':
1717
try:
1818
import ctypes
19-
PROCESS_SYSTEM_DPI_AWARE = 1
19+
PROCESS_SYSTEM_DPI_AWARE = 1 # Int required.
2020
ctypes.OleDLL('shcore').SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
2121
except (ImportError, AttributeError, OSError):
2222
pass
@@ -676,7 +676,6 @@ def execfile(self, filename, source=None):
676676
def runsource(self, source):
677677
"Extend base class method: Stuff the source in the line cache first"
678678
filename = self.stuffsource(source)
679-
self.more = 0
680679
# at the moment, InteractiveInterpreter expects str
681680
assert isinstance(source, str)
682681
# InteractiveInterpreter.runsource() calls its runcode() method,
@@ -993,12 +992,12 @@ def open_debugger(self):
993992
def beginexecuting(self):
994993
"Helper for ModifiedInterpreter"
995994
self.resetoutput()
996-
self.executing = 1
995+
self.executing = True
997996

998997
def endexecuting(self):
999998
"Helper for ModifiedInterpreter"
1000-
self.executing = 0
1001-
self.canceled = 0
999+
self.executing = False
1000+
self.canceled = False
10021001
self.showprompt()
10031002

10041003
def close(self):
@@ -1075,7 +1074,7 @@ def stop_readline(self):
10751074
def readline(self):
10761075
save = self.reading
10771076
try:
1078-
self.reading = 1
1077+
self.reading = True
10791078
self.top.mainloop() # nested mainloop()
10801079
finally:
10811080
self.reading = save
@@ -1087,11 +1086,11 @@ def readline(self):
10871086
line = "\n"
10881087
self.resetoutput()
10891088
if self.canceled:
1090-
self.canceled = 0
1089+
self.canceled = False
10911090
if not use_subprocess:
10921091
raise KeyboardInterrupt
10931092
if self.endoffile:
1094-
self.endoffile = 0
1093+
self.endoffile = False
10951094
line = ""
10961095
return line
10971096

@@ -1109,8 +1108,8 @@ def cancel_callback(self, event=None):
11091108
self.interp.write("KeyboardInterrupt\n")
11101109
self.showprompt()
11111110
return "break"
1112-
self.endoffile = 0
1113-
self.canceled = 1
1111+
self.endoffile = False
1112+
self.canceled = True
11141113
if (self.executing and self.interp.rpcclt):
11151114
if self.interp.getdebugger():
11161115
self.interp.restart_subprocess()
@@ -1130,8 +1129,8 @@ def eof_callback(self, event):
11301129
self.resetoutput()
11311130
self.close()
11321131
else:
1133-
self.canceled = 0
1134-
self.endoffile = 1
1132+
self.canceled = False
1133+
self.endoffile = True
11351134
self.top.quit()
11361135
return "break"
11371136

@@ -1303,7 +1302,7 @@ def write(self, s, tags=()):
13031302
raise ###pass # ### 11Aug07 KBK if we are expecting exceptions
13041303
# let's find out what they are and be specific.
13051304
if self.canceled:
1306-
self.canceled = 0
1305+
self.canceled = False
13071306
if not use_subprocess:
13081307
raise KeyboardInterrupt
13091308
return count

0 commit comments

Comments
 (0)