* Got entirely rid of path.py.
* Many modules: fixes for new, stricter, argument passing rules
  (most changes were automatic ones -- not all of this is tested!).
* gwin.py: now uses mainloop.py for its main loop and window admin.
* mainloop.py: always call dispatch() with event as a tuple!
* Fix bug in pdb's 'clear' command -- don't set the bpt but clear it!
diff --git a/Lib/lib-stdwin/Abstract.py b/Lib/lib-stdwin/Abstract.py
index c6fe137..51bd305 100644
--- a/Lib/lib-stdwin/Abstract.py
+++ b/Lib/lib-stdwin/Abstract.py
@@ -30,7 +30,7 @@
 	def getwindow(self): return unimpl() # Only for very special cases
 	#
 	def change(self, area): unimpl()
-	def scroll(self, (area, (dh, dv))): unimpl()
+	def scroll(self, area, (dh, dv)): unimpl()
 	def settimer(self, itimer): unimpl()
 
 class AbstractChild:
@@ -40,10 +40,10 @@
 	def destroy(self): unimpl()
 	#
 	def realize(self): return unimpl()
-	def getminsize(self, (m, (width, height))): return unimpl()
+	def getminsize(self, m, (width, height)): return unimpl()
 	def getbounds(self): return unimpl()
 	def setbounds(self, bounds): unimpl()
-	def draw(self, (d, area)): unimpl()
+	def draw(self, d, area): unimpl()
 	#
 	# Downcalls only made after certain upcalls
 	#
diff --git a/Lib/lib-stdwin/BoxParent.py b/Lib/lib-stdwin/BoxParent.py
index d042e88..a44995d 100644
--- a/Lib/lib-stdwin/BoxParent.py
+++ b/Lib/lib-stdwin/BoxParent.py
@@ -2,13 +2,13 @@
 
 class BoxParent(TransParent):
 	#
-	def create(self, (parent, (dh, dv))):
+	def create(self, parent, (dh, dv)):
 		self = TransParent.create(self, parent)
 		self.dh = dh
 		self.dv = dv
 		return self
 	#
-	def getminsize(self, (m, (width, height))):
+	def getminsize(self, m, (width, height)):
 		width = max(0, width - 2*self.dh)
 		height = max(0, height - 2*self.dv)
 		width, height = self.child.getminsize(m, (width, height))
diff --git a/Lib/lib-stdwin/Buttons.py b/Lib/lib-stdwin/Buttons.py
index d1435d3..9a99707 100644
--- a/Lib/lib-stdwin/Buttons.py
+++ b/Lib/lib-stdwin/Buttons.py
@@ -35,7 +35,7 @@
 	#
 	# Size enquiry
 	#
-	def getminsize(self, (m, (width, height))):
+	def getminsize(self, m, (width, height)):
 		width = max(width, m.textwidth(self.text) + 6)
 		height = max(height, m.lineheight() + 6)
 		return width, height
@@ -108,8 +108,8 @@
 			d.erase(self.bounds)
 			self.draw(d, self.bounds)
 	#
-	def draw(self, (d, area)):
-		area = _rect.intersect(area, self.bounds)
+	def draw(self, d, area):
+		area = _rect.intersect([area, self.bounds])
 		if area == _rect.empty:
 			return
 		d.cliprect(area)
@@ -145,7 +145,7 @@
 
 class StrutAppearance(LabelAppearance):
 	#
-	def getminsize(self, (m, (width, height))):
+	def getminsize(self, m, (width, height)):
 		height = max(height, m.lineheight() + 6)
 		return width, height
 	#
@@ -175,7 +175,7 @@
 #
 class CheckAppearance(LabelAppearance):
 	#
-	def getminsize(self, (m, (width, height))):
+	def getminsize(self, m, (width, height)):
 		minwidth = m.textwidth(self.text) + 6
 		minheight = m.lineheight() + 6
 		width = max(width, minwidth + minheight + m.textwidth(' '))
@@ -382,7 +382,7 @@
 	def destroy(self):
 		self.parent = 0
 	#
-	def definetext(self, (parent, text)):
+	def definetext(self, parent, text):
 		self = self.define(parent)
 		self.settext(text)
 		return self
diff --git a/Lib/lib-stdwin/CSplit.py b/Lib/lib-stdwin/CSplit.py
index 90d137e..90d5111 100644
--- a/Lib/lib-stdwin/CSplit.py
+++ b/Lib/lib-stdwin/CSplit.py
@@ -9,7 +9,7 @@
 
 class CSplit(Split):
 	#
-	def getminsize(self, (m, (width, height))):
+	def getminsize(self, m, (width, height)):
 		# Since things look best if the children are spaced evenly
 		# along the circle (and often all children have the same
 		# size anyway) we compute the max child size and assume
@@ -65,5 +65,5 @@
 			right, bottom = \
 				left + child_width, \
 				top + child_height
-			child.setbounds((left, top), (right, bottom))
+			child.setbounds(((left, top), (right, bottom)))
 	#
diff --git a/Lib/lib-stdwin/DirList.py b/Lib/lib-stdwin/DirList.py
index 00e9a8c..4b98b1d 100644
--- a/Lib/lib-stdwin/DirList.py
+++ b/Lib/lib-stdwin/DirList.py
@@ -11,7 +11,7 @@
 
 class DirList(VSplit):
 	#
-	def create(self, (parent, dirname)):
+	def create(self, parent, dirname):
 		self = VSplit.create(self, parent)
 		names = os.listdir(dirname)
 		for name in names:
diff --git a/Lib/lib-stdwin/FormSplit.py b/Lib/lib-stdwin/FormSplit.py
index 16f3293..271cb23 100644
--- a/Lib/lib-stdwin/FormSplit.py
+++ b/Lib/lib-stdwin/FormSplit.py
@@ -20,7 +20,7 @@
 		self.last_child = None
 		return Split.create(self, parent)
 	#
-	def getminsize(self, (m, sugg_size)):
+	def getminsize(self, m, sugg_size):
 		max_width, max_height = 0, 0
 		for c in self.children:
 			c.form_width, c.form_height = c.getminsize(m, (0, 0))
@@ -38,9 +38,9 @@
 		for c in self.children:
 			left, top = c.form_left + fleft, c.form_top + ftop
 			right, bottom = left + c.form_width, top + c.form_height
-			c.setbounds((left, top), (right, bottom))
+			c.setbounds(((left, top), (right, bottom)))
 	#
-	def placenext(self, (left, top)):
+	def placenext(self, left, top):
 		self.next_left = left
 		self.next_top = top
 		self.last_child = None
diff --git a/Lib/lib-stdwin/HVSplit.py b/Lib/lib-stdwin/HVSplit.py
index 9790b7b..c42327d 100644
--- a/Lib/lib-stdwin/HVSplit.py
+++ b/Lib/lib-stdwin/HVSplit.py
@@ -9,13 +9,13 @@
 
 class HVSplit(Split):
 	#
-	def create(self, (parent, hv)):
+	def create(self, parent, hv):
 		# hv is 0 for HSplit, 1 for VSplit
 		self = Split.create(self, parent)
 		self.hv = hv
 		return self
 	#
-	def getminsize(self, (m, sugg_size)):
+	def getminsize(self, m, sugg_size):
 		hv, vh = self.hv, 1 - self.hv
 		size = [0, 0]
 		sugg_size = [sugg_size[0], sugg_size[1]]
@@ -46,8 +46,8 @@
 			corner = [0, 0]
 			corner[vh] = end[vh]
 			corner[hv] = origin[hv] + size[hv]
-			c.setbounds((origin[0], origin[1]), \
-					(corner[0], corner[1]))
+			c.setbounds(((origin[0], origin[1]), \
+					(corner[0], corner[1])))
 			origin[hv] = corner[hv]
 			# XXX stretch
 			# XXX too-small
diff --git a/Lib/lib-stdwin/Histogram.py b/Lib/lib-stdwin/Histogram.py
index 27ae673..74a75f3 100644
--- a/Lib/lib-stdwin/Histogram.py
+++ b/Lib/lib-stdwin/Histogram.py
@@ -12,7 +12,7 @@
 		self.scale = (0, 100)
 		return self
 	#
-	def setdata(self, (ydata, scale)):
+	def setdata(self, ydata, scale):
 		self.ydata = ydata
 		self.scale = scale # (min, max)
 		self.parent.change(self.bounds)
diff --git a/Lib/lib-stdwin/Sliders.py b/Lib/lib-stdwin/Sliders.py
index 0a709d6..cbf776d 100644
--- a/Lib/lib-stdwin/Sliders.py
+++ b/Lib/lib-stdwin/Sliders.py
@@ -69,12 +69,12 @@
 	def sethook(self, hook):
 		self.hook = hook
 	#
-	def setminvalmax(self, (min, val, max)):
+	def setminvalmax(self, min, val, max):
 		self.min = min
 		self.max = max
 		self.setval(val)
 	#
-	def settexts(self, (pretext, postext)):
+	def settexts(self, pretext, postext):
 		self.pretext = pretext
 		self.postext = postext
 		self.recalctext()
@@ -95,7 +95,7 @@
 	#
 
 class DragSlider(DragSliderReactivity, DragSliderAppearance, Define):
-	def definetext(self, (parent, text)):
+	def definetext(self, parent, text):
 		raise RuntimeError, 'DragSlider.definetext() not supported'
 
 
@@ -108,7 +108,7 @@
 		return self
 	def setstep(self, step):
 		self.step = step
-	def definetextstep(self, (parent, text, step)):
+	def definetextstep(self, parent, text, step):
 		self = self.definetext(parent, text)
 		self.setstep(step)
 		return self
@@ -145,7 +145,7 @@
 	#
 	# Override HSplit methods
 	#
-	def getminsize(self, (m, (width, height))):
+	def getminsize(self, m, (width, height)):
 		w1, h1 = self.downbutton.getminsize(m, (0, height))
 		w3, h3 = self.upbutton.getminsize(m, (0, height))
 		w1 = max(w1, h1)
@@ -156,10 +156,10 @@
 	def setbounds(self, bounds):
 		(left, top), (right, bottom) = self.bounds = bounds
 		size = bottom - top
-		self.downbutton.setbounds((left, top), (left+size, bottom))
-		self.dragbutton.setbounds((left+size, top), \
-						(right-size, bottom))
-		self.upbutton.setbounds((right-size, top), (right, bottom))
+		self.downbutton.setbounds(((left, top), (left+size, bottom)))
+		self.dragbutton.setbounds(((left+size, top), \
+						(right-size, bottom)))
+		self.upbutton.setbounds(((right-size, top), (right, bottom)))
 	#
 	# Pass other Slider methods on to dragbutton
 	#
diff --git a/Lib/lib-stdwin/Soundogram.py b/Lib/lib-stdwin/Soundogram.py
index a68d4b3..e3c797e 100644
--- a/Lib/lib-stdwin/Soundogram.py
+++ b/Lib/lib-stdwin/Soundogram.py
@@ -5,7 +5,7 @@
 
 class Soundogram(Histogram):
 	#
-	def define(self, (win, chunk)):
+	def define(self, win, chunk):
 		width, height = corner = win.getwinsize()
 		bounds = (0, 0), corner
 		self.chunk = chunk
diff --git a/Lib/lib-stdwin/Split.py b/Lib/lib-stdwin/Split.py
index aacfa98..8eb0254 100644
--- a/Lib/lib-stdwin/Split.py
+++ b/Lib/lib-stdwin/Split.py
@@ -39,7 +39,7 @@
 		self.mouse_focus = None
 		self.keybd_focus = None
 	#
-	def getminsize(self, (m, (width, height))):
+	def getminsize(self, m, (width, height)):
 		return unimpl()			# Should ask children
 	def getbounds(self):
 		return unimpl()
diff --git a/Lib/lib-stdwin/StripChart.py b/Lib/lib-stdwin/StripChart.py
index 5bce412..afec007 100644
--- a/Lib/lib-stdwin/StripChart.py
+++ b/Lib/lib-stdwin/StripChart.py
@@ -8,7 +8,7 @@
 
 class StripChart(LabelAppearance, NoReactivity):
 	#
-	def define(self, (parent, scale)):
+	def define(self, parent, scale):
 		self.parent = parent
 		parent.addchild(self)
 		self.init_appearance()
@@ -49,8 +49,8 @@
 			area = (left+i-1, top), (left+i, bottom)
 			self.draw(self.parent.begindrawing(), area)
 	#
-	def draw(self, (d, area)):
-		area = rect.intersect(area, self.bounds)
+	def draw(self, d, area):
+		area = rect.intersect([area, self.bounds])
 		if area == rect.empty:
 			return
 		d.cliprect(area)
diff --git a/Lib/lib-stdwin/TextEdit.py b/Lib/lib-stdwin/TextEdit.py
index 698a7d5..e08e496 100644
--- a/Lib/lib-stdwin/TextEdit.py
+++ b/Lib/lib-stdwin/TextEdit.py
@@ -7,7 +7,7 @@
 
 class TextEdit:
 	#
-	def create(self, (parent, (cols, rows))):
+	def create(self, parent, (cols, rows)):
 		parent.addchild(self)
 		self.parent = parent
 		self.cols = cols
@@ -18,7 +18,7 @@
 		self.dh = self.dv = 0
 		return self
 	#
-	def createboxed(self, (parent, (cols, rows), (dh, dv))):
+	def createboxed(self, parent, (cols, rows), (dh, dv)):
 		self = self.create(parent, (cols, rows))
 		self.dh = max(0, dh)
 		self.dv = max(0, dv)
@@ -37,7 +37,7 @@
 		del self.editor
 		del self.window
 	#
-	def getminsize(self, (m, (width, height))):
+	def getminsize(self, m, (width, height)):
 		width = max(0, width - 2*self.dh)
 		height = max(0, height - 2*self.dv)
 		if width > 0 and self.editor:
@@ -96,7 +96,7 @@
 		self.parent.need_keybd(self)
 		self.parent.need_altdraw(self)
 	#
-	def draw(self, (d, area)):
+	def draw(self, d, area):
 		if self.dh and self.dv:
 			d.box(self.bounds)
 	#
@@ -114,7 +114,7 @@
 	def mouse_up(self, detail):
 		x = self.editor.event(WE_MOUSE_UP, self.window, detail)
 	#
-	def keybd(self, (type, detail)):
+	def keybd(self, type, detail):
 		x = self.editor.event(type, self.window, detail)
 	#
 	def activate(self):
diff --git a/Lib/lib-stdwin/WindowParent.py b/Lib/lib-stdwin/WindowParent.py
index 697ed07..1964d38 100644
--- a/Lib/lib-stdwin/WindowParent.py
+++ b/Lib/lib-stdwin/WindowParent.py
@@ -14,7 +14,7 @@
 
 class WindowParent(ManageOneChild):
 	#
-	def create(self, (title, size)):
+	def create(self, title, size):
 		self.title = title
 		self.size = size		# (width, height)
 		self._reset()
@@ -47,7 +47,7 @@
 	def close_trigger(self):
 		if self.close_hook: self.close_hook(self)
 	#
-	def menu_trigger(self, (menu, item)):
+	def menu_trigger(self, menu, item):
 		if self.menu_hook:
 			self.menu_hook(self, menu, item)
 	#
@@ -94,7 +94,7 @@
 			width = self.size[0]
 		if self.vbar:
 			height = self.size[1]
-		self.child.setbounds((0, 0), (width, height))
+		self.child.setbounds(((0, 0), (width, height)))
 		self.child.realize()
 		self.win.dispatch = self.dispatch
 		mainloop.register(self.win)
@@ -109,7 +109,7 @@
 			width = self.size[0]
 		if self.vbar:
 			height = self.size[1]
-		self.child.setbounds((0, 0), (width, height))
+		self.child.setbounds(((0, 0), (width, height)))
 		# Force a redraw of the entire window:
 		self.win.change((0, 0), self.size)
 	#
diff --git a/Lib/lib-stdwin/formatter.py b/Lib/lib-stdwin/formatter.py
index b2d4add..ac34ce9 100644
--- a/Lib/lib-stdwin/formatter.py
+++ b/Lib/lib-stdwin/formatter.py
@@ -13,7 +13,7 @@
 	# Pass the window's drawing object, and left, top, right
 	# coordinates of the drawing space as arguments.
 	#
-	def init(self, (d, left, top, right)):
+	def init(self, d, left, top, right):
 		self.d = d		# Drawing object
 		self.left = left	# Left margin
 		self.right = right	# Right margin
@@ -50,10 +50,10 @@
 	# of the current font's space width.
 	# (Two variations: one without, one with explicit stretch factor.)
 	#
-	def addword(self, (word, spacefactor)):
+	def addword(self, word, spacefactor):
 		self.addwordstretch(word, spacefactor, spacefactor)
 	#
-	def addwordstretch(self, (word, spacefactor, stretchfactor)):
+	def addwordstretch(self, word, spacefactor, stretchfactor):
 		width = self.d.textwidth(word)
 		if width > self.avail_width:
 			self._flush(1)
diff --git a/Lib/lib-stdwin/gwin.py b/Lib/lib-stdwin/gwin.py
index 12ed90b..626c8fa 100644
--- a/Lib/lib-stdwin/gwin.py
+++ b/Lib/lib-stdwin/gwin.py
@@ -2,16 +2,11 @@
 # Generic stdwin windows
 
 # This is used as a base class from which to derive other window types.
-# The mainloop() function here is an event dispatcher for all window types.
-
-# XXX This is really obsoleted by "mainloop.py".
-# XXX Also you should to it class-oriented...
+# XXX DON'T USE THIS CODE ANY MORE!  It is ages old!
 
 import stdwin, stdwinq
 from stdwinevents import *
-
-windows = []				# List of open windows
-
+from mainloop import mainloop, register, unregister, windows
 
 # Open a window
 
@@ -37,16 +32,11 @@
 	w.backspace = backspace
 	w.arrow = arrow
 	w.kleft = w.kup = w.kright = w.kdown = nop
-	windows.append(w)
+	w.dispatch = treatevent
+	register(w)
 	return w
 
 
-# Generic event dispatching
-
-def mainloop():				# Handle events until no windows left
-	while windows:
-		treatevent(stdwinq.getevent())
-
 def treatevent(e):			# Handle a stdwin event
 	type, w, detail = e
 	if type == WE_DRAW:
@@ -95,10 +85,9 @@
 # Methods
 
 def close(w):				# Close method
-	for i in range(len(windows)):
-		if windows[i] is w:
-			del windows[i]
-			break
+	unregister(w)
+	del w.close	# Delete our close function
+	w.close()	# Call the close method
 
 def arrow(w, detail):			# Arrow key method
 	if detail == WC_LEFT:
@@ -118,4 +107,4 @@
 def backspace(w): w.char(w, '\b')
 def m2down(w, detail): w.mdown(w, detail)
 def m2up(w, detail): w.mup(w, detail)
-def nop(args): pass
+def nop(*args): pass
diff --git a/Lib/lib-stdwin/mainloop.py b/Lib/lib-stdwin/mainloop.py
index ab8ad3a..f1fe617 100644
--- a/Lib/lib-stdwin/mainloop.py
+++ b/Lib/lib-stdwin/mainloop.py
@@ -23,7 +23,7 @@
 def register(win):
 	# First test the dispatch function by passing it a null event --
 	# this catches registration of unconforming windows.
-	win.dispatch(WE_NULL, win, None)
+	win.dispatch((WE_NULL, win, None))
 	if win not in windows:
 		windows.append(win)