Patch #2167 from calvin: Remove unused imports
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
index 249e237..7b6e867 100644
--- a/Lib/SimpleHTTPServer.py
+++ b/Lib/SimpleHTTPServer.py
@@ -14,7 +14,6 @@
 import posixpath
 import BaseHTTPServer
 import urllib
-import urlparse
 import cgi
 import shutil
 import mimetypes
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index c027ada..6d0fff1 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -4,7 +4,6 @@
 """
 
 import os
-import sys
 import errno
 import shutil
 import string
diff --git a/Lib/bsddb/test/test_compat.py b/Lib/bsddb/test/test_compat.py
index b108db4..bc165cf 100644
--- a/Lib/bsddb/test/test_compat.py
+++ b/Lib/bsddb/test/test_compat.py
@@ -3,7 +3,7 @@
 regression test suite.
 """
 
-import sys, os, string
+import os, string
 import unittest
 import tempfile
 
diff --git a/Lib/bsddb/test/test_cursor_pget_bug.py b/Lib/bsddb/test/test_cursor_pget_bug.py
index 2f72b11..2e83a6c 100644
--- a/Lib/bsddb/test/test_cursor_pget_bug.py
+++ b/Lib/bsddb/test/test_cursor_pget_bug.py
@@ -1,6 +1,6 @@
 import unittest
 import tempfile
-import sys, os, glob
+import os, glob
 
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/bsddb/test/test_dbobj.py b/Lib/bsddb/test/test_dbobj.py
index 6086d77..dd9909d 100644
--- a/Lib/bsddb/test/test_dbobj.py
+++ b/Lib/bsddb/test/test_dbobj.py
@@ -1,5 +1,5 @@
 
-import sys, os, string
+import os, string
 import unittest
 import glob
 import tempfile
diff --git a/Lib/bsddb/test/test_dbshelve.py b/Lib/bsddb/test/test_dbshelve.py
index ddc05d5..bd399a4 100644
--- a/Lib/bsddb/test/test_dbshelve.py
+++ b/Lib/bsddb/test/test_dbshelve.py
@@ -2,9 +2,8 @@
 TestCases for checking dbShelve objects.
 """
 
-import sys, os, string
+import os, string
 import tempfile, random
-from pprint import pprint
 from types import *
 import unittest
 
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
index 3a401e3..0c9cf5f 100644
--- a/Lib/bsddb/test/test_dbtables.py
+++ b/Lib/bsddb/test/test_dbtables.py
@@ -20,7 +20,7 @@
 #
 # $Id$
 
-import sys, os, re
+import os, re
 import tempfile
 import shutil
 try:
diff --git a/Lib/bsddb/test/test_env_close.py b/Lib/bsddb/test/test_env_close.py
index 5738feb..efc3460 100644
--- a/Lib/bsddb/test/test_env_close.py
+++ b/Lib/bsddb/test/test_env_close.py
@@ -3,7 +3,6 @@
 """
 
 import os
-import sys
 import tempfile
 import glob
 import unittest
diff --git a/Lib/bsddb/test/test_get_none.py b/Lib/bsddb/test/test_get_none.py
index 5f09cec..d6454cc 100644
--- a/Lib/bsddb/test/test_get_none.py
+++ b/Lib/bsddb/test/test_get_none.py
@@ -2,9 +2,8 @@
 TestCases for checking set_get_returns_none.
 """
 
-import sys, os, string
+import os, string
 import tempfile
-from pprint import pprint
 import unittest
 
 try:
diff --git a/Lib/bsddb/test/test_join.py b/Lib/bsddb/test/test_join.py
index 731f33a..26c2912 100644
--- a/Lib/bsddb/test/test_join.py
+++ b/Lib/bsddb/test/test_join.py
@@ -1,10 +1,8 @@
 """TestCases for using the DB.join and DBCursor.join_item methods.
 """
 
-import sys, os, string
+import os
 import tempfile
-import time
-from pprint import pprint
 
 try:
     from threading import Thread, currentThread
diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py
index e0d831f..18469a1 100644
--- a/Lib/bsddb/test/test_lock.py
+++ b/Lib/bsddb/test/test_lock.py
@@ -2,10 +2,7 @@
 TestCases for testing the locking sub-system.
 """
 
-import os
-from pprint import pprint
 import shutil
-import sys
 import tempfile
 import time
 
diff --git a/Lib/bsddb/test/test_misc.py b/Lib/bsddb/test/test_misc.py
index ef9c0aa..3d566f1 100644
--- a/Lib/bsddb/test/test_misc.py
+++ b/Lib/bsddb/test/test_misc.py
@@ -2,7 +2,6 @@
 """
 
 import os
-import sys
 import unittest
 import tempfile
 
diff --git a/Lib/bsddb/test/test_pickle.py b/Lib/bsddb/test/test_pickle.py
index ef84a40..b87cc68 100644
--- a/Lib/bsddb/test/test_pickle.py
+++ b/Lib/bsddb/test/test_pickle.py
@@ -1,5 +1,5 @@
 
-import sys, os, string
+import os
 import pickle
 try:
     import cPickle
diff --git a/Lib/bsddb/test/test_queue.py b/Lib/bsddb/test/test_queue.py
index 95cf20d..1acf35a 100644
--- a/Lib/bsddb/test/test_queue.py
+++ b/Lib/bsddb/test/test_queue.py
@@ -2,7 +2,7 @@
 TestCases for exercising a Queue DB.
 """
 
-import sys, os, string
+import os, string
 import tempfile
 from pprint import pprint
 import unittest
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
index 4b36a40..9630db1 100644
--- a/Lib/bsddb/test/test_recno.py
+++ b/Lib/bsddb/test/test_recno.py
@@ -2,7 +2,6 @@
 """
 
 import os
-import sys
 import errno
 import tempfile
 from pprint import pprint
diff --git a/Lib/bsddb/test/test_sequence.py b/Lib/bsddb/test/test_sequence.py
index 239e8ee..d7029e5 100644
--- a/Lib/bsddb/test/test_sequence.py
+++ b/Lib/bsddb/test/test_sequence.py
@@ -1,6 +1,5 @@
 import unittest
 import os
-import sys
 import tempfile
 import glob
 
@@ -10,8 +9,6 @@
 except ImportError:
     from bsddb import db
 
-from test_all import verbose
-
 
 class DBSequenceTest(unittest.TestCase):
     def setUp(self):
diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py
index 9c87db4..d14f6da 100644
--- a/Lib/bsddb/test/test_thread.py
+++ b/Lib/bsddb/test/test_thread.py
@@ -7,7 +7,6 @@
 import errno
 import shutil
 import tempfile
-from pprint import pprint
 from random import random
 
 try:
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index 77ac776..56cc1ef 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -29,7 +29,6 @@
 import parser
 import symbol
 import token
-import sys
 
 class WalkerError(StandardError):
     pass
diff --git a/Lib/ctypes/test/__init__.py b/Lib/ctypes/test/__init__.py
index 2b745c2..339ec8b 100644
--- a/Lib/ctypes/test/__init__.py
+++ b/Lib/ctypes/test/__init__.py
@@ -1,4 +1,4 @@
-import glob, os, sys, unittest, getopt, time
+import os, sys, unittest, getopt, time
 
 use_resources = []
 
diff --git a/Lib/ctypes/test/test_checkretval.py b/Lib/ctypes/test/test_checkretval.py
index 28be6c6..d15bd2e 100644
--- a/Lib/ctypes/test/test_checkretval.py
+++ b/Lib/ctypes/test/test_checkretval.py
@@ -1,5 +1,4 @@
 import unittest
-import sys
 
 from ctypes import *
 
diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
index 0cfe82e..ed1297d 100644
--- a/Lib/ctypes/test/test_find.py
+++ b/Lib/ctypes/test/test_find.py
@@ -1,5 +1,5 @@
 import unittest
-import os, sys
+import sys
 from ctypes import *
 from ctypes.util import find_library
 from ctypes.test import is_resource_enabled
diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
index c39f350..8d59f90 100644
--- a/Lib/ctypes/test/test_libc.py
+++ b/Lib/ctypes/test/test_libc.py
@@ -1,4 +1,3 @@
-import sys, os
 import unittest
 
 from ctypes import *
diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py
index 291fcca..4b95029 100644
--- a/Lib/ctypes/test/test_loading.py
+++ b/Lib/ctypes/test/test_loading.py
@@ -1,6 +1,6 @@
 from ctypes import *
 import sys, unittest
-import os, StringIO
+import os
 from ctypes.util import find_library
 from ctypes.test import is_resource_enabled
 
diff --git a/Lib/ctypes/test/test_numbers.py b/Lib/ctypes/test/test_numbers.py
index 5845741..dfd84ee 100644
--- a/Lib/ctypes/test/test_numbers.py
+++ b/Lib/ctypes/test/test_numbers.py
@@ -1,6 +1,6 @@
 from ctypes import *
 import unittest
-import sys, struct
+import struct
 
 def valid_ranges(*types):
     # given a sequence of numeric types, collect their _type_
diff --git a/Lib/curses/wrapper.py b/Lib/curses/wrapper.py
index 5335204..9f1d867 100644
--- a/Lib/curses/wrapper.py
+++ b/Lib/curses/wrapper.py
@@ -7,7 +7,7 @@
 
 """
 
-import sys, curses
+import curses
 
 def wrapper(func, *args, **kwds):
     """Wrapper function that initializes curses and calls another function,
diff --git a/Lib/distutils/bcppcompiler.py b/Lib/distutils/bcppcompiler.py
index ca524a5..d4fc533 100644
--- a/Lib/distutils/bcppcompiler.py
+++ b/Lib/distutils/bcppcompiler.py
@@ -16,7 +16,7 @@
 __revision__ = "$Id$"
 
 
-import sys, os
+import os
 from distutils.errors import \
      DistutilsExecError, DistutilsPlatformError, \
      CompileError, LibError, LinkError, UnknownFileError
diff --git a/Lib/distutils/command/bdist.py b/Lib/distutils/command/bdist.py
index 23c25a5..d6897d2 100644
--- a/Lib/distutils/command/bdist.py
+++ b/Lib/distutils/command/bdist.py
@@ -7,7 +7,7 @@
 
 __revision__ = "$Id$"
 
-import os, string
+import os
 from types import *
 from distutils.core import Command
 from distutils.errors import *
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py
index ccba009..f740c46 100644
--- a/Lib/distutils/command/bdist_dumb.py
+++ b/Lib/distutils/command/bdist_dumb.py
@@ -11,7 +11,7 @@
 import os
 from distutils.core import Command
 from distutils.util import get_platform
-from distutils.dir_util import create_tree, remove_tree, ensure_relative
+from distutils.dir_util import remove_tree, ensure_relative
 from distutils.errors import *
 from distutils.sysconfig import get_python_version
 from distutils import log
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index a1c0df4..a401452 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -7,7 +7,7 @@
 Implements the bdist_msi command.
 """
 
-import sys, os, string
+import sys, os
 from distutils.core import Command
 from distutils.util import get_platform
 from distutils.dir_util import remove_tree
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index 6f0e0d8..9aa7030 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -8,7 +8,6 @@
 __revision__ = "$Id$"
 
 import sys, os, string
-import glob
 from types import *
 from distutils.core import Command
 from distutils.debug import DEBUG
diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py
index b9f39ba..be6d2c5 100644
--- a/Lib/distutils/command/build_py.py
+++ b/Lib/distutils/command/build_py.py
@@ -6,7 +6,7 @@
 
 __revision__ = "$Id$"
 
-import sys, string, os
+import string, os
 from types import *
 from glob import glob
 
diff --git a/Lib/distutils/command/build_scripts.py b/Lib/distutils/command/build_scripts.py
index 6af363b..104be0b 100644
--- a/Lib/distutils/command/build_scripts.py
+++ b/Lib/distutils/command/build_scripts.py
@@ -6,7 +6,7 @@
 
 __revision__ = "$Id$"
 
-import sys, os, re
+import os, re
 from stat import ST_MODE
 from distutils import sysconfig
 from distutils.core import Command
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index c621210..0d39b91 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -17,7 +17,6 @@
 from distutils.file_util import write_file
 from distutils.util import convert_path, subst_vars, change_root
 from distutils.errors import DistutilsOptionError
-from glob import glob
 
 if sys.version < "2.2":
     WINDOWS_SCHEME = {
diff --git a/Lib/distutils/command/install_headers.py b/Lib/distutils/command/install_headers.py
index 2bd1b04..4895240 100644
--- a/Lib/distutils/command/install_headers.py
+++ b/Lib/distutils/command/install_headers.py
@@ -7,7 +7,6 @@
 
 __revision__ = "$Id$"
 
-import os
 from distutils.core import Command
 
 
diff --git a/Lib/distutils/command/install_lib.py b/Lib/distutils/command/install_lib.py
index 08ff543..81107a8 100644
--- a/Lib/distutils/command/install_lib.py
+++ b/Lib/distutils/command/install_lib.py
@@ -2,7 +2,7 @@
 
 __revision__ = "$Id$"
 
-import sys, os, string
+import os
 from types import IntType
 from distutils.core import Command
 from distutils.errors import DistutilsOptionError
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index d1a9100..5c588ef 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -7,7 +7,7 @@
 
 __revision__ = "$Id$"
 
-import sys, os, string, urllib2, getpass, urlparse
+import os, string, urllib2, getpass, urlparse
 import StringIO, ConfigParser
 
 from distutils.core import Command
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index a06b195..9b37f78 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -6,7 +6,7 @@
 
 __revision__ = "$Id$"
 
-import sys, os, string
+import os, string
 from types import *
 from glob import glob
 from distutils.core import Command
diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py
index 43f9aaa..6d27cce 100644
--- a/Lib/distutils/filelist.py
+++ b/Lib/distutils/filelist.py
@@ -11,7 +11,6 @@
 import os, string, re
 import fnmatch
 from types import *
-from glob import glob
 from distutils.util import convert_path
 from distutils.errors import DistutilsTemplateError, DistutilsInternalError
 from distutils import log
diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py
index 4d2a7cd..5ae7933 100644
--- a/Lib/distutils/tests/test_dist.py
+++ b/Lib/distutils/tests/test_dist.py
@@ -3,10 +3,8 @@
 import distutils.cmd
 import distutils.dist
 import os
-import shutil
 import StringIO
 import sys
-import tempfile
 import unittest
 
 from test.test_support import TESTFN
diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py
index 770b7c3..d56f7e9 100644
--- a/Lib/distutils/tests/test_sysconfig.py
+++ b/Lib/distutils/tests/test_sysconfig.py
@@ -2,7 +2,6 @@
 
 from distutils import sysconfig
 import os
-import sys
 import unittest
 
 from test.test_support import TESTFN
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
index 75e8a53..dc759ee 100644
--- a/Lib/distutils/unixccompiler.py
+++ b/Lib/distutils/unixccompiler.py
@@ -17,7 +17,6 @@
 
 import os, sys
 from types import StringType, NoneType
-from copy import copy
 
 from distutils import sysconfig
 from distutils.dep_util import newer
diff --git a/Lib/email/base64mime.py b/Lib/email/base64mime.py
index 0129d9d..8e76e43 100644
--- a/Lib/email/base64mime.py
+++ b/Lib/email/base64mime.py
@@ -35,7 +35,6 @@
     'header_encode',
     ]
 
-import re
 
 from binascii import b2a_base64, a2b_base64
 from email.utils import fix_eols
diff --git a/Lib/email/utils.py b/Lib/email/utils.py
index ee952d3..50010e6 100644
--- a/Lib/email/utils.py
+++ b/Lib/email/utils.py
@@ -27,7 +27,6 @@
 import socket
 import urllib
 import warnings
-from cStringIO import StringIO
 
 from email._parseaddr import quote
 from email._parseaddr import AddressList as _AddressList
diff --git a/Lib/hotshot/log.py b/Lib/hotshot/log.py
index 7d6d91d..99d0729 100644
--- a/Lib/hotshot/log.py
+++ b/Lib/hotshot/log.py
@@ -2,7 +2,6 @@
 import os.path
 import parser
 import symbol
-import sys
 
 from _hotshot import \
      WHAT_ENTER, \
diff --git a/Lib/hotshot/stones.py b/Lib/hotshot/stones.py
index cd4c51d..fb88d58 100644
--- a/Lib/hotshot/stones.py
+++ b/Lib/hotshot/stones.py
@@ -1,7 +1,6 @@
 import errno
 import hotshot
 import hotshot.stats
-import os
 import sys
 import test.pystone
 
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 6d27d24..c7d8e78 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -66,7 +66,6 @@
 Req-sent-unread-response       _CS_REQ_SENT       <response_class>
 """
 
-import errno
 import mimetools
 import socket
 from urlparse import urlsplit
diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py
index 547df13..51de639 100644
--- a/Lib/idlelib/MultiCall.py
+++ b/Lib/idlelib/MultiCall.py
@@ -30,7 +30,6 @@
 """
 
 import sys
-import os
 import string
 import re
 import Tkinter
diff --git a/Lib/idlelib/RemoteDebugger.py b/Lib/idlelib/RemoteDebugger.py
index 74085c3..fa234d1 100644
--- a/Lib/idlelib/RemoteDebugger.py
+++ b/Lib/idlelib/RemoteDebugger.py
@@ -20,7 +20,6 @@
 
 """
 
-import sys
 import types
 import rpc
 import Debugger
diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/TreeWidget.py
index c5c171f..5299e0e 100644
--- a/Lib/idlelib/TreeWidget.py
+++ b/Lib/idlelib/TreeWidget.py
@@ -15,7 +15,6 @@
 # - optimize tree redraw after expand of subnode
 
 import os
-import sys
 from Tkinter import *
 import imp
 
diff --git a/Lib/idlelib/UndoDelegator.py b/Lib/idlelib/UndoDelegator.py
index 182a117..5896bd5 100644
--- a/Lib/idlelib/UndoDelegator.py
+++ b/Lib/idlelib/UndoDelegator.py
@@ -1,4 +1,3 @@
-import sys
 import string
 from Tkinter import *
 from Delegator import Delegator
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index 010ab2c..acab053 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -11,7 +11,7 @@
 """
 from Tkinter import *
 import tkMessageBox, tkColorChooser, tkFont
-import string, copy
+import string
 
 from configHandler import idleConf
 from dynOptionMenuWidget import DynOptionMenu
diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/keybindingDialog.py
index aff9cac..1ce7ff4 100644
--- a/Lib/idlelib/keybindingDialog.py
+++ b/Lib/idlelib/keybindingDialog.py
@@ -3,7 +3,7 @@
 """
 from Tkinter import *
 import tkMessageBox
-import string, os
+import string
 
 class GetKeysDialog(Toplevel):
     def __init__(self,parent,title,action,currentKeySequences):
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 6e91982..7827c74 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -1,5 +1,4 @@
 import sys
-import os
 import linecache
 import time
 import socket
diff --git a/Lib/lib-tk/tkSimpleDialog.py b/Lib/lib-tk/tkSimpleDialog.py
index 03475f4..6948a49 100644
--- a/Lib/lib-tk/tkSimpleDialog.py
+++ b/Lib/lib-tk/tkSimpleDialog.py
@@ -26,7 +26,6 @@
 '''
 
 from Tkinter import *
-import os
 
 class Dialog(Toplevel):
 
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index e8081d6..a974e83 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -27,7 +27,7 @@
 To use, simply 'import logging' and log away!
 """
 
-import sys, logging, socket, types, os, string, cPickle, struct, time, glob
+import logging, socket, types, os, string, cPickle, struct, time, glob
 from stat import ST_DEV, ST_INO
 
 try:
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index c4a4ac5..59f1402 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -6,8 +6,8 @@
 """
 
 import os
-import stat
 import sys
+import stat
 import genericpath
 from genericpath import *
 
diff --git a/Lib/plat-mac/MiniAEFrame.py b/Lib/plat-mac/MiniAEFrame.py
index 98247cb..6a08dc9 100644
--- a/Lib/plat-mac/MiniAEFrame.py
+++ b/Lib/plat-mac/MiniAEFrame.py
@@ -6,7 +6,6 @@
         only suitable for the simplest of AppleEvent servers.
 """
 
-import sys
 import traceback
 import MacOS
 from Carbon import AE
diff --git a/Lib/plat-mac/aepack.py b/Lib/plat-mac/aepack.py
index 529a0a4..9ad9c44 100644
--- a/Lib/plat-mac/aepack.py
+++ b/Lib/plat-mac/aepack.py
@@ -13,18 +13,14 @@
 #
 
 import struct
-import string
 import types
-from string import strip
 from types import *
 from Carbon import AE
 from Carbon.AppleEvents import *
 import MacOS
 import Carbon.File
-import StringIO
 import aetypes
 from aetypes import mkenum, ObjectSpecifier
-import os
 
 # These ones seem to be missing from AppleEvents
 # (they're in AERegistry.h)
diff --git a/Lib/plat-mac/bgenlocations.py b/Lib/plat-mac/bgenlocations.py
index e7fa354..271eb3e 100644
--- a/Lib/plat-mac/bgenlocations.py
+++ b/Lib/plat-mac/bgenlocations.py
@@ -5,7 +5,7 @@
 # but mac-style for MacPython, whether running on OS9 or OSX.
 #
 
-import sys, os
+import os
 
 Error = "bgenlocations.Error"
 #
diff --git a/Lib/plat-mac/macostools.py b/Lib/plat-mac/macostools.py
index fc4861e..217f9e8 100644
--- a/Lib/plat-mac/macostools.py
+++ b/Lib/plat-mac/macostools.py
@@ -7,9 +7,7 @@
 from Carbon import Res
 from Carbon import File, Files
 import os
-import sys
 import MacOS
-import time
 try:
     openrf = MacOS.openrf
 except AttributeError:
diff --git a/Lib/plat-riscos/rourl2path.py b/Lib/plat-riscos/rourl2path.py
index 7a8badf..5d5386e 100644
--- a/Lib/plat-riscos/rourl2path.py
+++ b/Lib/plat-riscos/rourl2path.py
@@ -4,7 +4,6 @@
 
 import string
 import urllib
-import os
 
 __all__ = ["url2pathname","pathname2url"]
 
diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py
index 761bdaa..cb0a621 100644
--- a/Lib/sqlite3/test/hooks.py
+++ b/Lib/sqlite3/test/hooks.py
@@ -21,7 +21,7 @@
 #    misrepresented as being the original software.
 # 3. This notice may not be removed or altered from any source distribution.
 
-import os, unittest
+import unittest
 import sqlite3 as sqlite
 
 class CollationTests(unittest.TestCase):
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 9288144..24502e4 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -55,7 +55,7 @@
 PROTOCOL_TLSv1
 """
 
-import os, sys, textwrap
+import textwrap
 
 import _ssl             # if we can't import it, let the error propagate
 
diff --git a/Lib/test/fork_wait.py b/Lib/test/fork_wait.py
index 7eb55f6..3c75de3 100644
--- a/Lib/test/fork_wait.py
+++ b/Lib/test/fork_wait.py
@@ -13,7 +13,6 @@
 """
 
 import os, sys, time, thread, unittest
-from test.test_support import TestSkipped
 
 LONGSLEEP = 2
 SHORTSLEEP = 0.5
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py
index 88bc49d..b3f24d3 100644
--- a/Lib/test/list_tests.py
+++ b/Lib/test/list_tests.py
@@ -5,7 +5,6 @@
 import sys
 import os
 
-import unittest
 from test import test_support, seq_tests
 
 class CommonTest(seq_tests.CommonTest):
diff --git a/Lib/test/seq_tests.py b/Lib/test/seq_tests.py
index 2ea5094..d9b2d29 100644
--- a/Lib/test/seq_tests.py
+++ b/Lib/test/seq_tests.py
@@ -3,7 +3,6 @@
 """
 
 import unittest
-from test import test_support
 import sys
 
 # Various iterables
diff --git a/Lib/test/test_MimeWriter.py b/Lib/test/test_MimeWriter.py
index 5a20bf2..6a32cb6 100644
--- a/Lib/test/test_MimeWriter.py
+++ b/Lib/test/test_MimeWriter.py
@@ -7,7 +7,7 @@
 
 """
 
-import unittest, sys, StringIO
+import unittest, StringIO
 from test.test_support import run_unittest
 
 import warnings
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 26ed012..571e391 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -1,5 +1,5 @@
 import unittest
-from test.test_support import verbose, run_unittest
+from test.test_support import run_unittest
 import sys
 import warnings
 
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index ac5f7ee..c53dcea 100644
--- a/Lib/test/test_abc.py
+++ b/Lib/test/test_abc.py
@@ -3,7 +3,6 @@
 
 """Unit tests for abc.py."""
 
-import sys
 import unittest
 from test import test_support
 
diff --git a/Lib/test/test_applesingle.py b/Lib/test/test_applesingle.py
index d533f1a..e915028 100644
--- a/Lib/test/test_applesingle.py
+++ b/Lib/test/test_applesingle.py
@@ -5,7 +5,6 @@
 import Carbon.File
 import MacOS
 import os
-import sys
 from test import test_support
 import struct
 import applesingle
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 0bb7e53..a54594a 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -6,7 +6,7 @@
 import unittest
 from test import test_support
 from weakref import proxy
-import array, cStringIO, math
+import array, cStringIO
 from cPickle import loads, dumps
 
 class ArraySubclass(array.array):
diff --git a/Lib/test/test_bsddb185.py b/Lib/test/test_bsddb185.py
index df1ece0..51e1a7e 100644
--- a/Lib/test/test_bsddb185.py
+++ b/Lib/test/test_bsddb185.py
@@ -4,7 +4,7 @@
 testing suite.
 
 """
-from test.test_support import verbose, run_unittest, findfile
+from test.test_support import run_unittest, findfile
 import unittest
 import bsddb185
 import anydbm
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py
index 9cf3331..fc61d21 100644
--- a/Lib/test/test_class.py
+++ b/Lib/test/test_class.py
@@ -1,7 +1,6 @@
 "Test the functionality of Python classes implementing operators."
 
 import unittest
-import sys
 
 from test import test_support
 
diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py
index 5aa1c40..c08df0b 100644
--- a/Lib/test/test_cmd.py
+++ b/Lib/test/test_cmd.py
@@ -5,7 +5,6 @@
 """
 
 
-from test import test_support
 import cmd
 import sys
 
@@ -170,7 +169,7 @@
     from test import test_support, test_cmd
     test_support.run_doctest(test_cmd, verbose)
 
-import trace, sys,re,StringIO
+import trace, sys
 def test_coverage(coverdir):
     tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
                         trace=0, count=1)
diff --git a/Lib/test/test_coercion.py b/Lib/test/test_coercion.py
index d704e4b..e3a7e43 100644
--- a/Lib/test/test_coercion.py
+++ b/Lib/test/test_coercion.py
@@ -1,5 +1,4 @@
 import copy
-import sys
 import warnings
 import unittest
 from test.test_support import run_unittest, TestFailed
diff --git a/Lib/test/test_compare.py b/Lib/test/test_compare.py
index 2fde614..13da80d 100644
--- a/Lib/test/test_compare.py
+++ b/Lib/test/test_compare.py
@@ -1,4 +1,3 @@
-import sys
 import unittest
 from test import test_support
 
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py
index 606ed70..7d5ec7c 100644
--- a/Lib/test/test_compiler.py
+++ b/Lib/test/test_compiler.py
@@ -52,7 +52,8 @@
                         compiler.compile(buf, basename, "exec")
                     except Exception, e:
                         args = list(e.args)
-                        args[0] += "[in file %s]" % basename
+                        args.append("in file %s]" % basename)
+                        #args[0] += "[in file %s]" % basename
                         e.args = tuple(args)
                         raise
 
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index ff4c987..d2899bd 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -1,6 +1,5 @@
 """Unit tests for the copy module."""
 
-import sys
 import copy
 import copy_reg
 
diff --git a/Lib/test/test_cpickle.py b/Lib/test/test_cpickle.py
index 78beda7..d6e703a 100644
--- a/Lib/test/test_cpickle.py
+++ b/Lib/test/test_cpickle.py
@@ -1,5 +1,4 @@
 import cPickle
-import unittest
 from cStringIO import StringIO
 from test.pickletester import AbstractPickleTests, AbstractPickleModuleTests
 from test import test_support
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index cb639b4..ee104e4 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -4,7 +4,6 @@
 """
 
 import os
-import sys
 import pickle
 import cPickle
 import unittest
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index b93e72e..4da0932 100755
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -3,7 +3,6 @@
    Roger E. Masse
 """
 import os
-import random
 import dbm
 from dbm import error
 from test.test_support import verbose, verify, TestSkipped, TESTFN
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index e0ca746..b69110d 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -4,7 +4,6 @@
 from weakref import proxy
 import copy
 import cPickle as pickle
-from cStringIO import StringIO
 import random
 import os
 
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 4ed76ea..7dd5f06 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1,7 +1,7 @@
 import unittest
 from test import test_support
 
-import sys, UserDict, cStringIO, random, string
+import UserDict, random, string
 
 
 class DictTest(unittest.TestCase):
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index d0e1c7e..fd508a9 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -1,6 +1,6 @@
 # Minimal tests for dis module
 
-from test.test_support import verbose, run_unittest
+from test.test_support import run_unittest
 import unittest
 import sys
 import dis
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 8c8786a..943fb82 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -2418,7 +2418,7 @@
     from test import test_doctest
     test_support.run_doctest(test_doctest, verbosity=True)
 
-import trace, sys, re, StringIO
+import trace, sys
 def test_coverage(coverdir):
     tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
                          trace=0, count=1)
diff --git a/Lib/test/test_dummy_threading.py b/Lib/test/test_dummy_threading.py
index 3724f1e..dcb9729 100644
--- a/Lib/test/test_dummy_threading.py
+++ b/Lib/test/test_dummy_threading.py
@@ -3,7 +3,6 @@
 # Create a bunch of threads, let each do some work, wait until all are done
 
 from test.test_support import verbose
-import random
 import dummy_threading as _threading
 import time
 
diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py
index f609968..cb4ee60 100644
--- a/Lib/test/test_email.py
+++ b/Lib/test/test_email.py
@@ -1,7 +1,6 @@
 # Copyright (C) 2001,2002 Python Software Foundation
 # email package unit tests
 
-import unittest
 # The specific tests now live in Lib/email/test
 from email.test.test_email import suite
 from test import test_support
diff --git a/Lib/test/test_email_renamed.py b/Lib/test/test_email_renamed.py
index 163e791..2c814df 100644
--- a/Lib/test/test_email_renamed.py
+++ b/Lib/test/test_email_renamed.py
@@ -1,7 +1,6 @@
 # Copyright (C) 2001-2006 Python Software Foundation
 # email package unit tests
 
-import unittest
 # The specific tests now live in Lib/email/test
 from email.test.test_email_renamed import suite
 from test import test_support
diff --git a/Lib/test/test_eof.py b/Lib/test/test_eof.py
index aae3518..4d4c03b 100644
--- a/Lib/test/test_eof.py
+++ b/Lib/test/test_eof.py
@@ -1,7 +1,6 @@
 #! /usr/bin/env python
 """test script for a few new invalid token catches"""
 
-import os
 import unittest
 from test import test_support
 
diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py
index 96d1bc1..bdf8e03 100644
--- a/Lib/test/test_extcall.py
+++ b/Lib/test/test_extcall.py
@@ -1,4 +1,4 @@
-from test.test_support import verify, verbose, TestFailed, sortdict
+from test.test_support import verify, TestFailed, sortdict
 from UserList import UserList
 from UserDict import UserDict
 
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index f6589b7..9fb3ea7 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -6,7 +6,7 @@
 import unittest
 from test.test_support import verbose, TESTFN, run_unittest
 from test.test_support import unlink as safe_unlink
-import sys, os, re
+import sys, re
 from StringIO import StringIO
 from fileinput import FileInput, hook_encoded
 
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py
index 654456a..743f094 100644
--- a/Lib/test/test_fractions.py
+++ b/Lib/test/test_fractions.py
@@ -1,7 +1,7 @@
 """Tests for Lib/fractions.py."""
 
 from decimal import Decimal
-from test.test_support import run_unittest, verbose
+from test.test_support import run_unittest
 import math
 import operator
 import fractions
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index 90ca303..fa76fbc 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -1,8 +1,7 @@
 import unittest
 from test import test_support
-import sys
 
-import warnings, re
+import warnings
 warnings.filterwarnings("ignore",
                         category=DeprecationWarning,
                         message=".*integer argument expected, got float",
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py
index 124a469..1704a60 100644
--- a/Lib/test/test_gzip.py
+++ b/Lib/test/test_gzip.py
@@ -4,7 +4,7 @@
 
 import unittest
 from test import test_support
-import sys, os
+import os
 import gzip
 
 
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
index 229bbed..810af6c 100755
--- a/Lib/test/test_htmlparser.py
+++ b/Lib/test/test_htmlparser.py
@@ -2,7 +2,6 @@
 
 import HTMLParser
 import pprint
-import sys
 import unittest
 from test import test_support
 
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 6a20c6b..d312ae5 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1,6 +1,5 @@
 import httplib
 import StringIO
-import sys
 import socket
 
 from unittest import TestCase
diff --git a/Lib/test/test_imgfile.py b/Lib/test/test_imgfile.py
index bdfd796..11311c4 100755
--- a/Lib/test/test_imgfile.py
+++ b/Lib/test/test_imgfile.py
@@ -6,7 +6,7 @@
 
 from test.test_support import verbose, unlink, findfile
 
-import imgfile, uu, os
+import imgfile, uu
 
 
 def main():
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 62b14e0..f597728 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -1,5 +1,4 @@
 import imp
-import thread
 import unittest
 from test import test_support
 
diff --git a/Lib/test/test_index.py b/Lib/test/test_index.py
index 323b37b..75f2434 100644
--- a/Lib/test/test_index.py
+++ b/Lib/test/test_index.py
@@ -1,7 +1,6 @@
 import unittest
 from test import test_support
 import operator
-import sys
 from sys import maxint
 maxsize = test_support.MAX_Py_ssize_t
 minsize = -maxsize-1
diff --git a/Lib/test/test_linuxaudiodev.py b/Lib/test/test_linuxaudiodev.py
index 5d1d1ce..303490b 100644
--- a/Lib/test/test_linuxaudiodev.py
+++ b/Lib/test/test_linuxaudiodev.py
@@ -4,13 +4,9 @@
 from test.test_support import findfile, TestSkipped, run_unittest
 
 import errno
-import fcntl
 import linuxaudiodev
-import os
 import sys
-import select
 import sunaudio
-import time
 import audioop
 import unittest
 
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py
index 3489529..37507fe 100644
--- a/Lib/test/test_list.py
+++ b/Lib/test/test_list.py
@@ -1,4 +1,3 @@
-import unittest
 import sys
 from test import test_support, list_tests
 
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 1ed6cb2..5a96664 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1858,8 +1858,8 @@
 <BLANKLINE>
 """
 import select
-import os, sys, string, struct, types, cPickle, cStringIO
-import socket, tempfile, threading, time
+import os, sys, string, struct, cPickle, cStringIO
+import socket, threading
 import logging, logging.handlers, logging.config, test.test_support
 
 
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index fcc4c8f..97bca2c 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -3,7 +3,6 @@
 import os
 import sys
 import pickle
-import traceback
 from StringIO import StringIO
 from test.test_support import verbose, run_unittest, TestSkipped
 import unittest
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
index cc8b192..e0c7ec3 100644
--- a/Lib/test/test_module.py
+++ b/Lib/test/test_module.py
@@ -1,6 +1,6 @@
 # Test the module type
 import unittest
-from test.test_support import verbose, run_unittest
+from test.test_support import run_unittest
 
 import sys
 ModuleType = type(sys)
diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py
index 18cc322..b62758a 100644
--- a/Lib/test/test_modulefinder.py
+++ b/Lib/test/test_modulefinder.py
@@ -1,5 +1,5 @@
 import __future__
-import sys, os
+import os
 import unittest
 import distutils.dir_util
 import tempfile
diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py
index 57a4751..6055764 100644
--- a/Lib/test/test_multibytecodec_support.py
+++ b/Lib/test/test_multibytecodec_support.py
@@ -4,7 +4,7 @@
 #   Common Unittest Routines for CJK codecs
 #
 
-import sys, codecs, os.path
+import sys, codecs
 import unittest, re
 from test import test_support
 from StringIO import StringIO
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 38d5207..7a917d8 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -16,7 +16,6 @@
 import unittest
 
 from StringIO import StringIO
-from pprint import pprint
 from test import test_support
 
 
diff --git a/Lib/test/test_ossaudiodev.py b/Lib/test/test_ossaudiodev.py
index 83cc344..f2ce67b 100644
--- a/Lib/test/test_ossaudiodev.py
+++ b/Lib/test/test_ossaudiodev.py
@@ -1,14 +1,11 @@
 from test import test_support
 test_support.requires('audio')
 
-from test.test_support import verbose, findfile, TestSkipped
+from test.test_support import findfile, TestSkipped
 
 import errno
-import fcntl
 import ossaudiodev
-import os
 import sys
-import select
 import sunaudio
 import time
 import audioop
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index 585644e..fb10ffe 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -1,5 +1,4 @@
 import pickle
-import unittest
 from cStringIO import StringIO
 
 from test import test_support
diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py
index 28f9943..4fa367f 100644
--- a/Lib/test/test_pkg.py
+++ b/Lib/test/test_pkg.py
@@ -4,7 +4,6 @@
 import os
 import tempfile
 import textwrap
-import traceback
 import unittest
 from test import test_support
 
diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py
index 8e8d3e3..47630dc 100644
--- a/Lib/test/test_plistlib.py
+++ b/Lib/test/test_plistlib.py
@@ -3,7 +3,6 @@
 import unittest
 import plistlib
 import os
-import time
 import datetime
 from test import test_support
 
diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py
index 60cd3f4..5dbfc2c 100644
--- a/Lib/test/test_poll.py
+++ b/Lib/test/test_poll.py
@@ -1,6 +1,6 @@
 # Test case for the os.poll() function
 
-import sys, os, select, random, unittest
+import os, select, random, unittest
 from test.test_support import TestSkipped, TESTFN, run_unittest
 
 try:
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 7207de5..1fb3c48 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -9,7 +9,6 @@
 
 import time
 import os
-import sys
 import unittest
 import warnings
 warnings.filterwarnings('ignore', '.* potential security risk .*',
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 56fb683..d1291a0 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -3,7 +3,7 @@
    Nick Mathewson
 '''
 from test.test_support import run_unittest
-import unittest, sys
+import sys
 from types import ClassType, FunctionType, MethodType, BuiltinFunctionType
 import pyclbr
 from unittest import TestCase
diff --git a/Lib/test/test_quopri.py b/Lib/test/test_quopri.py
index 631c974..24a2f44 100644
--- a/Lib/test/test_quopri.py
+++ b/Lib/test/test_quopri.py
@@ -1,7 +1,7 @@
 from test import test_support
 import unittest
 
-import sys, os, cStringIO, subprocess
+import sys, cStringIO, subprocess
 import quopri
 
 
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 225f882..f354a1b 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -1,7 +1,6 @@
 import unittest
 from test import test_support
 
-import os
 import resource
 import time
 
diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py
index 6d22825..197887d 100644
--- a/Lib/test/test_rfc822.py
+++ b/Lib/test/test_rfc822.py
@@ -1,5 +1,4 @@
 import rfc822
-import sys
 import unittest
 from test import test_support
 
diff --git a/Lib/test/test_scriptpackages.py b/Lib/test/test_scriptpackages.py
index a2e03f9..ee14be2 100644
--- a/Lib/test/test_scriptpackages.py
+++ b/Lib/test/test_scriptpackages.py
@@ -1,9 +1,6 @@
 # Copyright (C) 2003 Python Software Foundation
 
 import unittest
-import os
-import sys
-import tempfile
 from test import test_support
 import aetools
 
diff --git a/Lib/test/test_sgmllib.py b/Lib/test/test_sgmllib.py
index b698636..d9c9ddc 100644
--- a/Lib/test/test_sgmllib.py
+++ b/Lib/test/test_sgmllib.py
@@ -1,4 +1,3 @@
-import htmlentitydefs
 import pprint
 import re
 import sgmllib
@@ -116,7 +115,7 @@
         try:
             events = self.get_events(source)
         except:
-            import sys
+            #import sys
             #print >>sys.stderr, pprint.pformat(self.events)
             raise
         if events != expected_events:
diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py
index 5c6572a..6c35f49 100644
--- a/Lib/test/test_shlex.py
+++ b/Lib/test/test_shlex.py
@@ -1,6 +1,5 @@
 # -*- coding: iso-8859-1 -*-
 import unittest
-import os, sys
 import shlex
 
 from test import test_support
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 3a8b9d3..c9957df 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -5,12 +5,11 @@
 
 """
 import unittest
-from test.test_support import TestSkipped, TestFailed, run_unittest, TESTFN
+from test.test_support import TestSkipped, run_unittest, TESTFN
 import __builtin__
 import os
 import sys
 import encodings
-import tempfile
 # Need to make sure to not import 'site' if someone specified ``-S`` at the
 # command-line.  Detect this by just making sure 'site' has not been imported
 # already.
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 79f3038..07dd778 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -9,7 +9,6 @@
 import select
 import time
 import threading
-from functools import wraps
 import unittest
 import SocketServer
 
diff --git a/Lib/test/test_sqlite.py b/Lib/test/test_sqlite.py
index f033772..c1523e1 100644
--- a/Lib/test/test_sqlite.py
+++ b/Lib/test/test_sqlite.py
@@ -1,5 +1,4 @@
 from test.test_support import run_unittest, TestSkipped
-import unittest
 
 try:
     import _sqlite3
diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py
index 7ea46bb..37db252 100644
--- a/Lib/test/test_str.py
+++ b/Lib/test/test_str.py
@@ -1,5 +1,4 @@
 
-import unittest
 import struct
 import sys
 from test import test_support, string_tests
diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py
index e9d3826..1105c00 100755
--- a/Lib/test/test_strftime.py
+++ b/Lib/test/test_strftime.py
@@ -2,7 +2,7 @@
 
 # Sanity checker for time.strftime
 
-import time, calendar, sys, os, re
+import time, calendar, sys, re
 from test.test_support import verbose
 
 def main():
diff --git a/Lib/test/test_sunaudiodev.py b/Lib/test/test_sunaudiodev.py
index f203d9a..3750542 100644
--- a/Lib/test/test_sunaudiodev.py
+++ b/Lib/test/test_sunaudiodev.py
@@ -1,4 +1,4 @@
-from test.test_support import verbose, findfile, TestFailed, TestSkipped
+from test.test_support import findfile, TestFailed, TestSkipped
 import sunaudiodev
 import os
 
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 9b4372c..d36d81c 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -10,7 +10,6 @@
 import os
 import os.path
 import warnings
-import types
 import unittest
 
 class Error(Exception):
diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py
index dddb03e..c413709 100644
--- a/Lib/test/test_tuple.py
+++ b/Lib/test/test_tuple.py
@@ -1,4 +1,3 @@
-import unittest
 from test import test_support, seq_tests
 
 class TupleTest(seq_tests.CommonTest):
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index ccb9411f..bdc7192 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -6,7 +6,7 @@
 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
 
 """#"
-import unittest, sys, struct, codecs, new
+import sys, struct, codecs
 from test import test_support, string_tests
 
 # Error handling (bad decoder return)
diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py
index 76a4822..7ddbc62 100644
--- a/Lib/test/test_unpack.py
+++ b/Lib/test/test_unpack.py
@@ -122,7 +122,6 @@
 __test__ = {'doctests' : doctests}
 
 def test_main(verbose=False):
-    import sys
     from test import test_support
     from test import test_unpack
     test_support.run_doctest(test_unpack, verbose)
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 455e7fc..0c669d0 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -8,10 +8,6 @@
 import mimetools
 import tempfile
 import StringIO
-import ftplib
-import threading
-import socket
-import time
 
 def hexescape(char):
     """Escape char as RFC 2396 specifies"""
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index a35cbfa..5727f8a 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -1,7 +1,7 @@
 import unittest
 from test import test_support
 
-import os, socket
+import os
 import StringIO
 
 import urllib2
@@ -589,7 +589,7 @@
             self.assertEqual(int(headers["Content-length"]), len(data))
 
     def test_file(self):
-        import time, rfc822, socket
+        import rfc822, socket
         h = urllib2.FileHandler()
         o = h.parent = MockOpener()
 
@@ -993,7 +993,7 @@
     def _test_basic_auth(self, opener, auth_handler, auth_header,
                          realm, http_handler, password_manager,
                          request_url, protected_url):
-        import base64, httplib
+        import base64
         user, password = "wile", "coyote"
 
         # .add_password() fed through to password manager
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index b347e82..54bf2d9 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -1,6 +1,5 @@
 #!/usr/bin/env python
 
-import sys
 import threading
 import urlparse
 import urllib2
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py
index 357c0f0..0818e98 100644
--- a/Lib/test/test_userdict.py
+++ b/Lib/test/test_userdict.py
@@ -1,6 +1,5 @@
 # Check every path through every method of UserDict
 
-import unittest
 from test import test_support, mapping_tests
 import UserDict
 
diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py
index 8c7ef2e..ed3e559 100644
--- a/Lib/test/test_userlist.py
+++ b/Lib/test/test_userlist.py
@@ -1,7 +1,6 @@
 # Check every path through every method of UserList
 
 from UserList import UserList
-import unittest
 from test import test_support, list_tests
 
 class UserListTest(list_tests.CommonTest):
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index b66dffe..06636fc 100755
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -2,7 +2,6 @@
 # UserString is a wrapper around the native builtin string type.
 # UserString instances should behave similar to builtin string objects.
 
-import unittest
 import string
 from test import test_support, string_tests
 
diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py
index 27d0d89..9aad56e 100644
--- a/Lib/test/test_uu.py
+++ b/Lib/test/test_uu.py
@@ -8,7 +8,6 @@
 
 import sys, os, uu, cStringIO
 import uu
-from StringIO import StringIO
 
 plaintext = "The smooth-scaled python crept over the sleeping dog\n"
 
diff --git a/Lib/test/test_whichdb.py b/Lib/test/test_whichdb.py
index f2652c1..1ce816f 100644
--- a/Lib/test/test_whichdb.py
+++ b/Lib/test/test_whichdb.py
@@ -8,7 +8,6 @@
 import unittest
 import whichdb
 import anydbm
-import tempfile
 import glob
 
 _fname = test.test_support.TESTFN
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 78adb42..65c99f1 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -2,7 +2,8 @@
 # all included components work as they should.  For a more extensive
 # test suite, see the selftest script in the ElementTree distribution.
 
-import doctest, sys
+import doctest
+import sys
 
 from test import test_support
 
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index 250f791..7ddd44b 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -1,6 +1,7 @@
 # xml.etree test for cElementTree
 
-import doctest, sys
+import doctest
+import sys
 
 from test import test_support
 
diff --git a/Lib/test/test_xpickle.py b/Lib/test/test_xpickle.py
index 42cd0f4..3ffb744 100644
--- a/Lib/test/test_xpickle.py
+++ b/Lib/test/test_xpickle.py
@@ -5,7 +5,6 @@
 
 import pickle
 import cPickle
-import unittest
 
 from test import test_support
 from test.pickletester import AbstractPickleTests
diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py
index 449cf39..6ce2ae5 100644
--- a/Lib/test/test_zipfile64.py
+++ b/Lib/test/test_zipfile64.py
@@ -20,7 +20,6 @@
 import time
 import sys
 
-from StringIO import StringIO
 from tempfile import TemporaryFile
 
 from test.test_support import TESTFN, run_unittest
diff --git a/Mac/Demo/PICTbrowse/ICONbrowse.py b/Mac/Demo/PICTbrowse/ICONbrowse.py
index 701ef7f..f55070b 100644
--- a/Mac/Demo/PICTbrowse/ICONbrowse.py
+++ b/Mac/Demo/PICTbrowse/ICONbrowse.py
@@ -7,8 +7,6 @@
 from Carbon import Win
 from Carbon import Controls
 from Carbon import List
-import sys
-import struct
 from Carbon import Icn
 import macresource
 
diff --git a/Mac/Demo/PICTbrowse/PICTbrowse.py b/Mac/Demo/PICTbrowse/PICTbrowse.py
index 0adfc83..f92bdd0 100644
--- a/Mac/Demo/PICTbrowse/PICTbrowse.py
+++ b/Mac/Demo/PICTbrowse/PICTbrowse.py
@@ -7,7 +7,6 @@
 from Carbon import Win
 from Carbon import Controls
 from Carbon import List
-import sys
 import struct
 import macresource
 
diff --git a/Mac/Demo/PICTbrowse/PICTbrowse2.py b/Mac/Demo/PICTbrowse/PICTbrowse2.py
index 84cf8b8..211d09e 100644
--- a/Mac/Demo/PICTbrowse/PICTbrowse2.py
+++ b/Mac/Demo/PICTbrowse/PICTbrowse2.py
@@ -7,7 +7,6 @@
 from Carbon import Win
 from Carbon import Controls
 from Carbon import List
-import sys
 import struct
 import macresource
 
diff --git a/Mac/Demo/PICTbrowse/cicnbrowse.py b/Mac/Demo/PICTbrowse/cicnbrowse.py
index d95e7c8..4bc7008 100644
--- a/Mac/Demo/PICTbrowse/cicnbrowse.py
+++ b/Mac/Demo/PICTbrowse/cicnbrowse.py
@@ -7,8 +7,6 @@
 from Carbon import Win
 from Carbon import Controls
 from Carbon import List
-import sys
-import struct
 from Carbon import Icn
 import macresource
 
diff --git a/Mac/Demo/PICTbrowse/oldPICTbrowse.py b/Mac/Demo/PICTbrowse/oldPICTbrowse.py
index 8600bb2..d15a27d 100644
--- a/Mac/Demo/PICTbrowse/oldPICTbrowse.py
+++ b/Mac/Demo/PICTbrowse/oldPICTbrowse.py
@@ -6,7 +6,6 @@
 from Carbon import Qd
 from Carbon import Win
 from Carbon import List
-import sys
 import struct
 import macresource
 
diff --git a/Mac/Demo/example1/dnslookup-1.py b/Mac/Demo/example1/dnslookup-1.py
index 2fb8dc4..6eb2c73 100644
--- a/Mac/Demo/example1/dnslookup-1.py
+++ b/Mac/Demo/example1/dnslookup-1.py
@@ -4,7 +4,6 @@
 import EasyDialogs
 from Carbon import Res
 from Carbon import Dlg
-import sys
 import socket
 import string
 import macresource
diff --git a/Mac/Demo/example2/dnslookup-2.py b/Mac/Demo/example2/dnslookup-2.py
index 92cd181..fc3db66 100644
--- a/Mac/Demo/example2/dnslookup-2.py
+++ b/Mac/Demo/example2/dnslookup-2.py
@@ -2,7 +2,6 @@
 import EasyDialogs
 from Carbon import Res
 from Carbon import Dlg
-import sys
 import socket
 import string
 import macresource
diff --git a/Mac/Demo/imgbrowse/imgbrowse.py b/Mac/Demo/imgbrowse/imgbrowse.py
index 28dffd3..e38e5d8 100644
--- a/Mac/Demo/imgbrowse/imgbrowse.py
+++ b/Mac/Demo/imgbrowse/imgbrowse.py
@@ -7,11 +7,9 @@
 from Carbon import QuickDraw
 from Carbon import Win
 #ifrom Carbon mport List
-import sys
 import struct
 import img
 import imgformat
-import struct
 import mac_image
 
 
diff --git a/Mac/Demo/imgbrowse/mac_image.py b/Mac/Demo/imgbrowse/mac_image.py
index 9c9eeb7..b6fb274 100644
--- a/Mac/Demo/imgbrowse/mac_image.py
+++ b/Mac/Demo/imgbrowse/mac_image.py
@@ -1,7 +1,6 @@
 """mac_image - Helper routines (hacks) for images"""
 import imgformat
 from Carbon import Qd
-import time
 import struct
 import MacOS
 
diff --git a/Mac/Demo/sound/morse.py b/Mac/Demo/sound/morse.py
index b26d554..b6919c5 100644
--- a/Mac/Demo/sound/morse.py
+++ b/Mac/Demo/sound/morse.py
@@ -1,4 +1,4 @@
-import sys, math, audiodev
+import sys, math
 
 DOT = 30
 DAH = 80
diff --git a/Mac/Modules/ae/aescan.py b/Mac/Modules/ae/aescan.py
index 1283c1d..ce19a5e 100644
--- a/Mac/Modules/ae/aescan.py
+++ b/Mac/Modules/ae/aescan.py
@@ -3,8 +3,6 @@
 # (Should learn how to tell the compiler to compile it as well.)
 
 import sys
-import os
-import string
 import MacOS
 
 from bgenlocations import TOOLBOXDIR, BGENDIR
diff --git a/Mac/Modules/ah/ahscan.py b/Mac/Modules/ah/ahscan.py
index 0b7fe08..b993427 100644
--- a/Mac/Modules/ah/ahscan.py
+++ b/Mac/Modules/ah/ahscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner_OSX
diff --git a/Mac/Modules/app/appscan.py b/Mac/Modules/app/appscan.py
index 1b04859..94eee47 100644
--- a/Mac/Modules/app/appscan.py
+++ b/Mac/Modules/app/appscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/carbonevt/CarbonEvtscan.py b/Mac/Modules/carbonevt/CarbonEvtscan.py
index e3c72ae..31e2336 100644
--- a/Mac/Modules/carbonevt/CarbonEvtscan.py
+++ b/Mac/Modules/carbonevt/CarbonEvtscan.py
@@ -1,8 +1,6 @@
 # IBCarbonscan.py
 
 import sys
-import os
-import string
 import MacOS
 import sys
 
diff --git a/Mac/Modules/cf/cfscan.py b/Mac/Modules/cf/cfscan.py
index d2de92e..6de4f1e 100644
--- a/Mac/Modules/cf/cfscan.py
+++ b/Mac/Modules/cf/cfscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner_OSX
diff --git a/Mac/Modules/cg/cgscan.py b/Mac/Modules/cg/cgscan.py
index b2e7946..c08394e 100755
--- a/Mac/Modules/cg/cgscan.py
+++ b/Mac/Modules/cg/cgscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner_OSX
diff --git a/Mac/Modules/cm/cmscan.py b/Mac/Modules/cm/cmscan.py
index 087f239..73261f5 100644
--- a/Mac/Modules/cm/cmscan.py
+++ b/Mac/Modules/cm/cmscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py
index 25333f1..9cb30d1 100644
--- a/Mac/Modules/ctl/ctlscan.py
+++ b/Mac/Modules/ctl/ctlscan.py
@@ -1,6 +1,5 @@
 # Scan <Controls.h>, generating ctlgen.py.
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 
diff --git a/Mac/Modules/dlg/dlgscan.py b/Mac/Modules/dlg/dlgscan.py
index 7fb68f7..a4d6d5b 100644
--- a/Mac/Modules/dlg/dlgscan.py
+++ b/Mac/Modules/dlg/dlgscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 
diff --git a/Mac/Modules/drag/dragscan.py b/Mac/Modules/drag/dragscan.py
index 923a56b..bd419c4 100644
--- a/Mac/Modules/drag/dragscan.py
+++ b/Mac/Modules/drag/dragscan.py
@@ -1,6 +1,5 @@
 # Scan <Drag.h>, generating draggen.py.
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR, INCLUDEDIR
 sys.path.append(BGENDIR)
 
diff --git a/Mac/Modules/evt/evtscan.py b/Mac/Modules/evt/evtscan.py
index 0d0c9ec..ea0692c 100644
--- a/Mac/Modules/evt/evtscan.py
+++ b/Mac/Modules/evt/evtscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/file/filescan.py b/Mac/Modules/file/filescan.py
index 8ebc69f..4b70823 100644
--- a/Mac/Modules/file/filescan.py
+++ b/Mac/Modules/file/filescan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner_OSX
diff --git a/Mac/Modules/fm/fmscan.py b/Mac/Modules/fm/fmscan.py
index 334d5ec..1c0d412 100644
--- a/Mac/Modules/fm/fmscan.py
+++ b/Mac/Modules/fm/fmscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/folder/folderscan.py b/Mac/Modules/folder/folderscan.py
index 8c94893..746a333 100644
--- a/Mac/Modules/folder/folderscan.py
+++ b/Mac/Modules/folder/folderscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner_OSX
diff --git a/Mac/Modules/help/helpscan.py b/Mac/Modules/help/helpscan.py
index 50e0919..b3543b9 100644
--- a/Mac/Modules/help/helpscan.py
+++ b/Mac/Modules/help/helpscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/ibcarbon/IBCarbonscan.py b/Mac/Modules/ibcarbon/IBCarbonscan.py
index 84e4f1e..f71f864 100644
--- a/Mac/Modules/ibcarbon/IBCarbonscan.py
+++ b/Mac/Modules/ibcarbon/IBCarbonscan.py
@@ -1,8 +1,6 @@
 # IBCarbonscan.py
 
 import sys
-import os
-import string
 
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
diff --git a/Mac/Modules/icn/icnscan.py b/Mac/Modules/icn/icnscan.py
index bdc3b84..6af3a4e 100644
--- a/Mac/Modules/icn/icnscan.py
+++ b/Mac/Modules/icn/icnscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/launch/launchscan.py b/Mac/Modules/launch/launchscan.py
index 621033b..3e07238 100644
--- a/Mac/Modules/launch/launchscan.py
+++ b/Mac/Modules/launch/launchscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/list/listscan.py b/Mac/Modules/list/listscan.py
index 877f6cb..a027459 100644
--- a/Mac/Modules/list/listscan.py
+++ b/Mac/Modules/list/listscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/menu/menuscan.py b/Mac/Modules/menu/menuscan.py
index ae9465e..8151581 100644
--- a/Mac/Modules/menu/menuscan.py
+++ b/Mac/Modules/menu/menuscan.py
@@ -1,6 +1,5 @@
 # Scan <Menus.h>, generating menugen.py.
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 
diff --git a/Mac/Modules/mlte/mltescan.py b/Mac/Modules/mlte/mltescan.py
index adecb4f..e48a229 100644
--- a/Mac/Modules/mlte/mltescan.py
+++ b/Mac/Modules/mlte/mltescan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner_OSX
diff --git a/Mac/Modules/osa/osascan.py b/Mac/Modules/osa/osascan.py
index fb8196f..5fc2e9f 100644
--- a/Mac/Modules/osa/osascan.py
+++ b/Mac/Modules/osa/osascan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/qd/qdscan.py b/Mac/Modules/qd/qdscan.py
index 85a8cdc..24fbb74 100644
--- a/Mac/Modules/qd/qdscan.py
+++ b/Mac/Modules/qd/qdscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 
diff --git a/Mac/Modules/qdoffs/qdoffsscan.py b/Mac/Modules/qdoffs/qdoffsscan.py
index d456e00..0ad9802 100644
--- a/Mac/Modules/qdoffs/qdoffsscan.py
+++ b/Mac/Modules/qdoffs/qdoffsscan.py
@@ -1,6 +1,5 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 
diff --git a/Mac/Modules/qt/qtscan.py b/Mac/Modules/qt/qtscan.py
index a2dba15..cd00124 100644
--- a/Mac/Modules/qt/qtscan.py
+++ b/Mac/Modules/qt/qtscan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/res/resscan.py b/Mac/Modules/res/resscan.py
index 47a97e4..6966e85 100644
--- a/Mac/Modules/res/resscan.py
+++ b/Mac/Modules/res/resscan.py
@@ -3,8 +3,6 @@
 # (Should learn how to tell the compiler to compile it as well.)
 
 import sys
-import os
-import string
 import MacOS
 
 from bgenlocations import TOOLBOXDIR, BGENDIR
diff --git a/Mac/Modules/scrap/scrapscan.py b/Mac/Modules/scrap/scrapscan.py
index 1fc8191..25a683c 100644
--- a/Mac/Modules/scrap/scrapscan.py
+++ b/Mac/Modules/scrap/scrapscan.py
@@ -4,7 +4,6 @@
 # generates a boilerplate to be edited by hand.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/snd/sndscan.py b/Mac/Modules/snd/sndscan.py
index c4a8266..7504aef 100644
--- a/Mac/Modules/snd/sndscan.py
+++ b/Mac/Modules/snd/sndscan.py
@@ -3,7 +3,6 @@
 # (Should learn how to tell the compiler to compile it as well.)
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 
diff --git a/Mac/Modules/te/tescan.py b/Mac/Modules/te/tescan.py
index f5b6fff..6cd25f4 100644
--- a/Mac/Modules/te/tescan.py
+++ b/Mac/Modules/te/tescan.py
@@ -1,7 +1,6 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 from scantools import Scanner
diff --git a/Mac/Modules/win/winscan.py b/Mac/Modules/win/winscan.py
index f78935d..8a2f726 100644
--- a/Mac/Modules/win/winscan.py
+++ b/Mac/Modules/win/winscan.py
@@ -1,6 +1,5 @@
 # Scan an Apple header file, generating a Python file of generator calls.
 import sys
-import os
 from bgenlocations import TOOLBOXDIR, BGENDIR
 sys.path.append(BGENDIR)
 
diff --git a/Misc/BeOS-setup.py b/Misc/BeOS-setup.py
index 991e608..0043a34 100644
--- a/Misc/BeOS-setup.py
+++ b/Misc/BeOS-setup.py
@@ -4,7 +4,7 @@
 
 __version__ = "special BeOS after 1.37"
 
-import sys, os, getopt
+import sys, os
 from distutils import sysconfig
 from distutils import text_file
 from distutils.errors import *
diff --git a/PC/VS8.0/build_tkinter.py b/PC/VS8.0/build_tkinter.py
index defafe8..ea59039 100644
--- a/PC/VS8.0/build_tkinter.py
+++ b/PC/VS8.0/build_tkinter.py
@@ -7,7 +7,6 @@
 
 import os
 import sys
-import shutil
 
 here = os.path.abspath(os.path.dirname(__file__))
 par = os.path.pardir
diff --git a/PCbuild/build_tkinter.py b/PCbuild/build_tkinter.py
index 574d768..0590b0f 100644
--- a/PCbuild/build_tkinter.py
+++ b/PCbuild/build_tkinter.py
@@ -7,7 +7,6 @@
 
 import os
 import sys
-import shutil
 
 here = os.path.abspath(os.path.dirname(__file__))
 par = os.path.pardir
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 4877853..17d9dfd 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -4,7 +4,7 @@
 # TO DO
 # handle fields that have a type but no name
 
-import os, sys, traceback
+import os, sys
 
 import asdl
 
diff --git a/Parser/spark.py b/Parser/spark.py
index 2c18623..b064d62 100644
--- a/Parser/spark.py
+++ b/Parser/spark.py
@@ -22,7 +22,6 @@
 __version__ = 'SPARK-0.7 (pre-alpha-5)'
 
 import re
-import sys
 import string
 
 def _namelist(instance):
diff --git a/Tools/compiler/astgen.py b/Tools/compiler/astgen.py
index 59b98f2..c431d22 100644
--- a/Tools/compiler/astgen.py
+++ b/Tools/compiler/astgen.py
@@ -8,7 +8,6 @@
 """
 
 import fileinput
-import getopt
 import re
 import sys
 from StringIO import StringIO
diff --git a/Tools/compiler/dumppyc.py b/Tools/compiler/dumppyc.py
index 1258cce..39b9613 100755
--- a/Tools/compiler/dumppyc.py
+++ b/Tools/compiler/dumppyc.py
@@ -1,7 +1,6 @@
 #! /usr/bin/env python
 
 import marshal
-import os
 import dis
 import types
 
diff --git a/Tools/faqwiz/faqw.py b/Tools/faqwiz/faqw.py
index a26e0d6..c6c1a6d 100755
--- a/Tools/faqwiz/faqw.py
+++ b/Tools/faqwiz/faqw.py
@@ -20,7 +20,7 @@
 try:
     FAQDIR = "/usr/people/guido/python/FAQ"
     SRCDIR = "/usr/people/guido/python/src/Tools/faqwiz"
-    import os, sys, time, operator
+    import os, sys
     os.chdir(FAQDIR)
     sys.path.insert(0, SRCDIR)
     import faqwiz
diff --git a/Tools/modulator/Tkextra.py b/Tools/modulator/Tkextra.py
index 8f55728..1227106 100755
--- a/Tools/modulator/Tkextra.py
+++ b/Tools/modulator/Tkextra.py
@@ -218,7 +218,6 @@
                   0, 'Save', 'Save as text')
 
 def _test():
-    import sys
     global mainWidget
     mainWidget = Frame()
     Pack.config(mainWidget)
diff --git a/Tools/pybench/systimes.py b/Tools/pybench/systimes.py
index bf07e36..c4b952e 100644
--- a/Tools/pybench/systimes.py
+++ b/Tools/pybench/systimes.py
@@ -31,7 +31,7 @@
     the author. All Rights Reserved.
 
 """
-import time, sys, struct
+import time, sys
 
 #
 # Note: Please keep this module compatible to Python 1.5.2.
diff --git a/Tools/pynche/ChipViewer.py b/Tools/pynche/ChipViewer.py
index 05412ce..f59aa28 100644
--- a/Tools/pynche/ChipViewer.py
+++ b/Tools/pynche/ChipViewer.py
@@ -13,7 +13,6 @@
 selected and nearest ChipWidgets.
 """
 
-from types import StringType
 from Tkinter import *
 import ColorDB
 
diff --git a/Tools/pynche/TypeinViewer.py b/Tools/pynche/TypeinViewer.py
index bcc3cda..d56c1b3 100644
--- a/Tools/pynche/TypeinViewer.py
+++ b/Tools/pynche/TypeinViewer.py
@@ -12,8 +12,6 @@
 you must hit Return or Tab to select the color.
 """
 
-import sys
-import re
 from Tkinter import *
 
 
diff --git a/Tools/scripts/logmerge.py b/Tools/scripts/logmerge.py
index edfec2c..c63819c 100755
--- a/Tools/scripts/logmerge.py
+++ b/Tools/scripts/logmerge.py
@@ -34,7 +34,7 @@
 from their output.
 """
 
-import os, sys, errno, getopt, re
+import sys, errno, getopt, re
 
 sep1 = '='*77 + '\n'                    # file separator
 sep2 = '-'*28 + '\n'                    # revision separator
diff --git a/Tools/scripts/nm2def.py b/Tools/scripts/nm2def.py
index 6887ee2..5f2bc8f 100755
--- a/Tools/scripts/nm2def.py
+++ b/Tools/scripts/nm2def.py
@@ -34,7 +34,7 @@
 option to produce this format (since it is the original v7 Unix format).
 
 """
-import os,re,sys
+import os, sys
 
 PYTHONLIB = 'libpython'+sys.version[:3]+'.a'
 PC_PYTHONLIB = 'Python'+sys.version[0]+sys.version[2]+'.dll'
diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py
index 89ed9e6..ec440d1 100755
--- a/Tools/scripts/pindent.py
+++ b/Tools/scripts/pindent.py
@@ -81,7 +81,6 @@
 TABSIZE = 8
 EXPANDTABS = 0
 
-import os
 import re
 import sys
 
diff --git a/Tools/scripts/pysource.py b/Tools/scripts/pysource.py
index 71e0ded..a295303 100644
--- a/Tools/scripts/pysource.py
+++ b/Tools/scripts/pysource.py
@@ -20,7 +20,7 @@
 __all__ = ["has_python_ext", "looks_like_python", "can_be_compiled", "walk_python_files"]
 
 
-import sys, os, re
+import os, re
 
 binary_re = re.compile('[\x00-\x08\x0E-\x1F\x7F]')
 
diff --git a/Tools/scripts/xxci.py b/Tools/scripts/xxci.py
index c6a7d08..ebb044d 100755
--- a/Tools/scripts/xxci.py
+++ b/Tools/scripts/xxci.py
@@ -7,7 +7,6 @@
 import sys
 import os
 from stat import *
-import commands
 import fnmatch
 
 EXECMAGIC = '\001\140\000\010'
diff --git a/Tools/ssl/get-remote-certificate.py b/Tools/ssl/get-remote-certificate.py
index cbcd76f..b63428a 100644
--- a/Tools/ssl/get-remote-certificate.py
+++ b/Tools/ssl/get-remote-certificate.py
@@ -6,7 +6,7 @@
 #
 # By Bill Janssen.
 
-import sys, os
+import sys
 
 def fetch_server_certificate (host, port):
 
diff --git a/Tools/unicode/gencodec.py b/Tools/unicode/gencodec.py
index 8a2ca64..431a76d 100644
--- a/Tools/unicode/gencodec.py
+++ b/Tools/unicode/gencodec.py
@@ -26,7 +26,7 @@
 
 """#"
 
-import re, os, time, marshal, codecs
+import re, os, marshal, codecs
 
 # Maximum allowed size of charmap tables
 MAX_TABLE_SIZE = 8192
diff --git a/Tools/webchecker/wcgui.py b/Tools/webchecker/wcgui.py
index 96aed0a..cfc4098 100755
--- a/Tools/webchecker/wcgui.py
+++ b/Tools/webchecker/wcgui.py
@@ -63,7 +63,6 @@
 from Tkinter import *
 import tktools
 import webchecker
-import random
 
 # Override some for a weaker platform
 if sys.platform == 'mac':
diff --git a/Tools/webchecker/wsgui.py b/Tools/webchecker/wsgui.py
index 0c851ca..95c7ab9 100755
--- a/Tools/webchecker/wsgui.py
+++ b/Tools/webchecker/wsgui.py
@@ -7,9 +7,7 @@
 """
 
 from Tkinter import *
-import Tkinter
 import websucker
-import sys
 import os
 import threading
 import Queue