Skip to content

Commit

Permalink
Added a _v21 def to FL.py and added two new input field types
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
gvanrossum committed Sep 2, 1992
1 parent 2179945 commit 4e16098
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 160 deletions.
37 changes: 25 additions & 12 deletions Lib/bdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def dispatch_exception(self, frame, arg):
return self.trace_dispatch

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

def stop_here(self, frame):
Expand All @@ -93,28 +93,28 @@ def break_here(self, frame):
def break_anywhere(self, frame):
return self.breaks.has_key(frame.f_code.co_filename)

# Derived classes should override the user_* functions
# Derived classes should override the user_* methods
# to gain control.

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

def user_line(self, frame):
# This function is called when we stop or break at this line
# This method is called when we stop or break at this line
pass

def user_return(self, frame, return_value):
# This function is called when a return trap is set here
# This method is called when a return trap is set here
pass

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

# Derived classes and clients can call the following functions
# Derived classes and clients can call the following methods
# to affect the stepping state.

def set_step(self):
Expand Down Expand Up @@ -147,8 +147,8 @@ def set_quit(self):
self.quitting = 1
sys.settrace(None)

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

Expand Down Expand Up @@ -196,7 +196,7 @@ def get_file_breaks(self, filename):
def get_all_breaks(self):
return self.breaks

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

def get_stack(self, f, t):
Expand Down Expand Up @@ -234,7 +234,7 @@ def format_stack_entry(self, (frame, lineno)):
if line: s = s + ': ' + string.strip(line)
return s

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

def run(self, cmd):
Expand All @@ -253,7 +253,20 @@ def runctx(self, cmd, globals, locals):
finally:
self.quitting = 1
sys.settrace(None)
# XXX What to do if the command finishes normally?

# This method is more useful to debug a single function call.

def runcall(self, func, *args):
self.reset()
sys.settrace(self.trace_dispatch)
try:
try:
apply(func, args)
except BdbQuit:
pass
finally:
self.quitting = 1
sys.settrace(None)


# -------------------- testing --------------------
Expand Down
23 changes: 23 additions & 0 deletions Lib/bisect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Bisection algorithms


# Insert item x in list a, and keep it sorted assuming a is sorted

def insort(a, x):
lo, hi = 0, len(a)
while lo < hi:
mid = (lo+hi)/2
if x < a[mid]: hi = mid
else: lo = mid+1
a.insert(lo, x)


# Find the index where to insert item x in list a, assuming a is sorted

def bisect(a, x):
lo, hi = 0, len(a)
while lo < hi:
mid = (lo+hi)/2
if x < a[mid]: hi = mid
else: lo = mid+1
return lo
4 changes: 4 additions & 0 deletions Lib/irix5/FL.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Alternate use: from FL import *; ... NORMAL_BOX ... etc.

_v20 = 1
_v21 = 1
##import fl
##try:
## _v20 = (fl.get_rgbmode <> None)
Expand Down Expand Up @@ -198,6 +199,9 @@
FLOAT_INPUT = 1
INT_INPUT = 2
HIDDEN_INPUT = 3
if _v21:
MULTILINE_INPUT = 4
SECRET_INPUT = 5
else:
ALWAYS_INPUT = 1
INPUT_BOXTYPE = DOWN_BOX
Expand Down
5 changes: 5 additions & 0 deletions Lib/lib-stdwin/wdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ def runctx(statement, globals, locals):
try: x.runctx(statement, globals, locals)
finally: x.close()

def runcall(*args):
x = Wdb().init()
try: apply(Pdb().init().runcall, args)
finally: x.close()

TESTCMD = 'import x; x.main()'

def test():
Expand Down
3 changes: 3 additions & 0 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ def run(statement):
def runctx(statement, globals, locals):
Pdb().init().runctx(statement, globals, locals)

def runcall(*args):
apply(Pdb().init().runcall, args)

TESTCMD = 'import x; x.main()'

def test():
Expand Down
4 changes: 4 additions & 0 deletions Lib/plat-irix5/FL.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Alternate use: from FL import *; ... NORMAL_BOX ... etc.

_v20 = 1
_v21 = 1
##import fl
##try:
## _v20 = (fl.get_rgbmode <> None)
Expand Down Expand Up @@ -198,6 +199,9 @@
FLOAT_INPUT = 1
INT_INPUT = 2
HIDDEN_INPUT = 3
if _v21:
MULTILINE_INPUT = 4
SECRET_INPUT = 5
else:
ALWAYS_INPUT = 1
INPUT_BOXTYPE = DOWN_BOX
Expand Down
Loading

0 comments on commit 4e16098

Please sign in to comment.