Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e16098

Browse files
committed
Added a _v21 def to FL.py and added two new input field types
Added runcall(func, *args) interfaces to profile.py, bdb.py, pdb.py, wdb.py Added new module bisect.py and used it in sched.py. Mostly cosmetic changes to profile.py (changed output format).
1 parent 2179945 commit 4e16098

9 files changed

Lines changed: 167 additions & 160 deletions

File tree

Lib/bdb.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def dispatch_exception(self, frame, arg):
6868
return self.trace_dispatch
6969

7070
# Normally derived classes don't override the following
71-
# functions, but they may if they want to redefine the
71+
# methods, but they may if they want to redefine the
7272
# definition of stopping and breakpoints.
7373

7474
def stop_here(self, frame):
@@ -93,28 +93,28 @@ def break_here(self, frame):
9393
def break_anywhere(self, frame):
9494
return self.breaks.has_key(frame.f_code.co_filename)
9595

96-
# Derived classes should override the user_* functions
96+
# Derived classes should override the user_* methods
9797
# to gain control.
9898

9999
def user_call(self, frame, argument_list):
100-
# This function is called when there is the remote possibility
100+
# This method is called when there is the remote possibility
101101
# that we ever need to stop in this function
102102
pass
103103

104104
def user_line(self, frame):
105-
# This function is called when we stop or break at this line
105+
# This method is called when we stop or break at this line
106106
pass
107107

108108
def user_return(self, frame, return_value):
109-
# This function is called when a return trap is set here
109+
# This method is called when a return trap is set here
110110
pass
111111

112112
def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
113-
# This function is called if an exception occurs,
113+
# This method is called if an exception occurs,
114114
# but only if we are to stop at or just below this level
115115
pass
116116

117-
# Derived classes and clients can call the following functions
117+
# Derived classes and clients can call the following methods
118118
# to affect the stepping state.
119119

120120
def set_step(self):
@@ -147,8 +147,8 @@ def set_quit(self):
147147
self.quitting = 1
148148
sys.settrace(None)
149149

150-
# Derived classes and clients can call the following functions
151-
# to manipulate breakpoints. These functions return an
150+
# Derived classes and clients can call the following methods
151+
# to manipulate breakpoints. These methods return an
152152
# error message is something went wrong, None if all is well.
153153
# Call self.get_*break*() to see the breakpoints.
154154

@@ -196,7 +196,7 @@ def get_file_breaks(self, filename):
196196
def get_all_breaks(self):
197197
return self.breaks
198198

199-
# Derived classes and clients can call the following function
199+
# Derived classes and clients can call the following method
200200
# to get a data structure representing a stack trace.
201201

202202
def get_stack(self, f, t):
@@ -234,7 +234,7 @@ def format_stack_entry(self, (frame, lineno)):
234234
if line: s = s + ': ' + string.strip(line)
235235
return s
236236

237-
# The following two functions can be called by clients to use
237+
# The following two methods can be called by clients to use
238238
# a debugger to debug a statement, given as a string.
239239

240240
def run(self, cmd):
@@ -253,7 +253,20 @@ def runctx(self, cmd, globals, locals):
253253
finally:
254254
self.quitting = 1
255255
sys.settrace(None)
256-
# XXX What to do if the command finishes normally?
256+
257+
# This method is more useful to debug a single function call.
258+
259+
def runcall(self, func, *args):
260+
self.reset()
261+
sys.settrace(self.trace_dispatch)
262+
try:
263+
try:
264+
apply(func, args)
265+
except BdbQuit:
266+
pass
267+
finally:
268+
self.quitting = 1
269+
sys.settrace(None)
257270

258271

259272
# -------------------- testing --------------------

Lib/bisect.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Bisection algorithms
2+
3+
4+
# Insert item x in list a, and keep it sorted assuming a is sorted
5+
6+
def insort(a, x):
7+
lo, hi = 0, len(a)
8+
while lo < hi:
9+
mid = (lo+hi)/2
10+
if x < a[mid]: hi = mid
11+
else: lo = mid+1
12+
a.insert(lo, x)
13+
14+
15+
# Find the index where to insert item x in list a, assuming a is sorted
16+
17+
def bisect(a, x):
18+
lo, hi = 0, len(a)
19+
while lo < hi:
20+
mid = (lo+hi)/2
21+
if x < a[mid]: hi = mid
22+
else: lo = mid+1
23+
return lo

Lib/irix5/FL.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Alternate use: from FL import *; ... NORMAL_BOX ... etc.
55

66
_v20 = 1
7+
_v21 = 1
78
##import fl
89
##try:
910
## _v20 = (fl.get_rgbmode <> None)
@@ -198,6 +199,9 @@
198199
FLOAT_INPUT = 1
199200
INT_INPUT = 2
200201
HIDDEN_INPUT = 3
202+
if _v21:
203+
MULTILINE_INPUT = 4
204+
SECRET_INPUT = 5
201205
else:
202206
ALWAYS_INPUT = 1
203207
INPUT_BOXTYPE = DOWN_BOX

Lib/lib-stdwin/wdb.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ def runctx(statement, globals, locals):
283283
try: x.runctx(statement, globals, locals)
284284
finally: x.close()
285285

286+
def runcall(*args):
287+
x = Wdb().init()
288+
try: apply(Pdb().init().runcall, args)
289+
finally: x.close()
290+
286291
TESTCMD = 'import x; x.main()'
287292

288293
def test():

Lib/pdb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ def run(statement):
254254
def runctx(statement, globals, locals):
255255
Pdb().init().runctx(statement, globals, locals)
256256

257+
def runcall(*args):
258+
apply(Pdb().init().runcall, args)
259+
257260
TESTCMD = 'import x; x.main()'
258261

259262
def test():

Lib/plat-irix5/FL.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Alternate use: from FL import *; ... NORMAL_BOX ... etc.
55

66
_v20 = 1
7+
_v21 = 1
78
##import fl
89
##try:
910
## _v20 = (fl.get_rgbmode <> None)
@@ -198,6 +199,9 @@
198199
FLOAT_INPUT = 1
199200
INT_INPUT = 2
200201
HIDDEN_INPUT = 3
202+
if _v21:
203+
MULTILINE_INPUT = 4
204+
SECRET_INPUT = 5
201205
else:
202206
ALWAYS_INPUT = 1
203207
INPUT_BOXTYPE = DOWN_BOX

0 commit comments

Comments
 (0)