Issue #26778: Fixed "a/an/and" typos in code comment and documentation.
diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py
index d324a21..122430e 100644
--- a/Lib/SocketServer.py
+++ b/Lib/SocketServer.py
@@ -707,7 +707,7 @@
             try:
                 self.wfile.flush()
             except socket.error:
-                # An final socket error may have occurred here, such as
+                # A final socket error may have occurred here, such as
                 # the local error ECONNABORTED.
                 pass
         self.wfile.close()
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 694b778..d8e1ee7 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -420,7 +420,7 @@
         return self.__closed
 
     def _checkClosed(self, msg=None):
-        """Internal: raise an ValueError if file is closed
+        """Internal: raise a ValueError if file is closed
         """
         if self.closed:
             raise ValueError("I/O operation on closed file."
@@ -2022,7 +2022,7 @@
 
     def __repr__(self):
         # TextIOWrapper tells the encoding in its repr. In StringIO,
-        # that's a implementation detail.
+        # that's an implementation detail.
         return object.__repr__(self)
 
     @property
diff --git a/Lib/calendar.py b/Lib/calendar.py
index d3bd236..4c95a49 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -142,7 +142,7 @@
 
     def iterweekdays(self):
         """
-        Return a iterator for one week of weekday numbers starting with the
+        Return an iterator for one week of weekday numbers starting with the
         configured first one.
         """
         for i in range(self.firstweekday, self.firstweekday + 7):
diff --git a/Lib/decimal.py b/Lib/decimal.py
index d274552..20d9468 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -224,7 +224,7 @@
 class ConversionSyntax(InvalidOperation):
     """Trying to convert badly formed string.
 
-    This occurs and signals invalid-operation if an string is being
+    This occurs and signals invalid-operation if a string is being
     converted to a number and it does not conform to the numeric string
     syntax.  The result is [0,qNaN].
     """
diff --git a/Lib/difflib.py b/Lib/difflib.py
index 3880d84..1c6fbdb 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -1487,7 +1487,7 @@
                 yield _make_line(lines,'-',0), None, True
                 continue
             elif s.startswith(('--?+', '--+', '- ')):
-                # in delete block and see a intraline change or unchanged line
+                # in delete block and see an intraline change or unchanged line
                 # coming: yield the delete line and then blanks
                 from_line,to_line = _make_line(lines,'-',0), None
                 num_blanks_to_yield,num_blanks_pending = num_blanks_pending-1,0
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index 5d11687..c72a249 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -10,9 +10,9 @@
 #
 # * if you use a msvc compiled python version (1.5.2)
 #   1. you have to insert a __GNUC__ section in its config.h
-#   2. you have to generate a import library for its dll
+#   2. you have to generate an import library for its dll
 #      - create a def-file for python??.dll
-#      - create a import library using
+#      - create an import library using
 #             dlltool --dllname python15.dll --def python15.def \
 #                       --output-lib libpython15.a
 #
diff --git a/Lib/getopt.py b/Lib/getopt.py
index 251d89c..084aadb 100644
--- a/Lib/getopt.py
+++ b/Lib/getopt.py
@@ -28,7 +28,7 @@
 # - RETURN_IN_ORDER option
 # - GNU extension with '-' as first character of option string
 # - optional arguments, specified by double colons
-# - a option string with a W followed by semicolon should
+# - an option string with a W followed by semicolon should
 #   treat "-W foo" as "--foo"
 
 __all__ = ["GetoptError","error","getopt","gnu_getopt"]
diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py
index 1248f00..5a90d42 100644
--- a/Lib/idlelib/AutoComplete.py
+++ b/Lib/idlelib/AutoComplete.py
@@ -67,7 +67,7 @@
 
     def try_open_completions_event(self, event):
         """Happens when it would be nice to open a completion list, but not
-        really necessary, for example after an dot, so function
+        really necessary, for example after a dot, so function
         calls won't be made.
         """
         lastchar = self.text.get("insert-1c")
diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/Debugger.py
index 7fbe4a7..c517065 100644
--- a/Lib/idlelib/Debugger.py
+++ b/Lib/idlelib/Debugger.py
@@ -373,7 +373,7 @@
     def __init__(self, master, flist, gui):
         if macosxSupport.isAquaTk():
             # At least on with the stock AquaTk version on OSX 10.4 you'll
-            # get an shaking GUI that eventually kills IDLE if the width
+            # get a shaking GUI that eventually kills IDLE if the width
             # argument is specified.
             ScrolledList.__init__(self, master)
         else:
diff --git a/Lib/idlelib/WidgetRedirector.py b/Lib/idlelib/WidgetRedirector.py
index 2cb9398..54431f7 100644
--- a/Lib/idlelib/WidgetRedirector.py
+++ b/Lib/idlelib/WidgetRedirector.py
@@ -68,7 +68,7 @@
         '''Return OriginalCommand(operation) after registering function.
 
         Registration adds an operation: function pair to ._operations.
-        It also adds an widget function attribute that masks the Tkinter
+        It also adds a widget function attribute that masks the Tkinter
         class instance method.  Method masking operates independently
         from command dispatch.
 
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index 585a871..671882b 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -1213,7 +1213,7 @@
 
         All values are treated as text, and it is up to the user to supply
         reasonable values. The only exception to this are the 'enable*' options,
-        which are boolean, and can be toggled with an True/False button.
+        which are boolean, and can be toggled with a True/False button.
         """
         parent = self.parent
         frame = self.tabPages.pages['Extensions'].frame
diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py
index 1f28e56..d723e47 100644
--- a/Lib/lib-tk/Tix.py
+++ b/Lib/lib-tk/Tix.py
@@ -221,7 +221,7 @@
         self.tk.eval('package require Tix')
 
     def destroy(self):
-        # For safety, remove an delete_window binding before destroy
+        # For safety, remove the delete_window binding before destroy
         self.protocol("WM_DELETE_WINDOW", "")
         Tkinter.Tk.destroy(self)
 
@@ -702,7 +702,7 @@
 
 class ExFileSelectBox(TixWidget):
     """ExFileSelectBox - MS Windows style file select box.
-    It provides an convenient method for the user to select files.
+    It provides a convenient method for the user to select files.
 
     Subwidget       Class
     ---------       -----
@@ -760,7 +760,7 @@
 # Should inherit from a Dialog class
 class ExFileSelectDialog(TixWidget):
     """ExFileSelectDialog - MS Windows style file select dialog.
-    It provides an convenient method for the user to select files.
+    It provides a convenient method for the user to select files.
 
     Subwidgets       Class
     ----------       -----
diff --git a/Lib/lib-tk/Tkdnd.py b/Lib/lib-tk/Tkdnd.py
index 2e37d9e..1b09f91 100644
--- a/Lib/lib-tk/Tkdnd.py
+++ b/Lib/lib-tk/Tkdnd.py
@@ -3,7 +3,7 @@
 This is very preliminary.  I currently only support dnd *within* one
 application, between different windows (or within the same window).
 
-I an trying to make this as generic as possible -- not dependent on
+I am trying to make this as generic as possible -- not dependent on
 the use of a particular widget or icon type, etc.  I also hope that
 this will work with Pmw.
 
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index d8d5b80..7944819 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -2778,7 +2778,7 @@
                     self.deletecommand(c)
         self.tk.call(self._w, 'delete', index1, index2)
     def entrycget(self, index, option):
-        """Return the resource value of an menu item for OPTION at INDEX."""
+        """Return the resource value of a menu item for OPTION at INDEX."""
         return self.tk.call(self._w, 'entrycget', index, '-' + option)
     def entryconfigure(self, index, cnf=None, **kw):
         """Configure a menu item at INDEX."""
diff --git a/Lib/lib-tk/test/test_ttk/test_functions.py b/Lib/lib-tk/test/test_ttk/test_functions.py
index 714d950..ea3f81c 100644
--- a/Lib/lib-tk/test/test_ttk/test_functions.py
+++ b/Lib/lib-tk/test/test_ttk/test_functions.py
@@ -195,7 +195,7 @@
 
         ## Testing type = vsapi
         # vsapi type expects at least a class name and a part_id, so this
-        # should raise an ValueError since it tries to get two elements from
+        # should raise a ValueError since it tries to get two elements from
         # an empty tuple
         self.assertRaises(ValueError, ttk._format_elemcreate, 'vsapi')
 
diff --git a/Lib/lib-tk/ttk.py b/Lib/lib-tk/ttk.py
index 08cb040..fe73aef 100644
--- a/Lib/lib-tk/ttk.py
+++ b/Lib/lib-tk/ttk.py
@@ -291,7 +291,7 @@
     """Format options then call Tk command with args and options and return
     the appropriate result.
 
-    If no option is specified, a dict is returned. If a option is
+    If no option is specified, a dict is returned. If an option is
     specified with the None value, the value for that option is returned.
     Otherwise, the function just sets the passed options and the caller
     shouldn't be expecting a return value anyway."""
@@ -1476,7 +1476,7 @@
     can be accessed through instance.label"""
 
     def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
-        """Construct an horizontal LabeledScale with parent master, a
+        """Construct a horizontal LabeledScale with parent master, a
         variable to be associated with the Ttk Scale widget and its range.
         If variable is not specified, a Tkinter.IntVar is created.
 
diff --git a/Lib/lib2to3/fixer_base.py b/Lib/lib2to3/fixer_base.py
index f6421ba..d437b96 100644
--- a/Lib/lib2to3/fixer_base.py
+++ b/Lib/lib2to3/fixer_base.py
@@ -50,7 +50,7 @@
         """Initializer.  Subclass may override.
 
         Args:
-            options: an dict containing the options passed to RefactoringTool
+            options: a dict containing the options passed to RefactoringTool
             that could be used to customize the fixer through the command line.
             log: a list to append warnings and other messages to.
         """
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
index bd23897..98386c5 100644
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -184,7 +184,7 @@
 
         Args:
             fixer_names: a list of fixers to import
-            options: an dict with configuration.
+            options: a dict with configuration.
             explicit: a list of fixers to run even if they are explicit.
         """
         self.fixers = fixer_names
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index 3866953..b1e5faa 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -1774,7 +1774,7 @@
     """Message with Babyl-specific properties."""
 
     def __init__(self, message=None):
-        """Initialize an BabylMessage instance."""
+        """Initialize a BabylMessage instance."""
         self._labels = []
         self._visible = Message()
         Message.__init__(self, message)
diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py
index 08d35d8..7763965 100644
--- a/Lib/multiprocessing/managers.py
+++ b/Lib/multiprocessing/managers.py
@@ -884,7 +884,7 @@
 
 def MakeProxyType(name, exposed, _cache={}):
     '''
-    Return an proxy type whose methods are given by `exposed`
+    Return a proxy type whose methods are given by `exposed`
     '''
     exposed = tuple(exposed)
     try:
diff --git a/Lib/optparse.py b/Lib/optparse.py
index 433276d..f8c70dd 100644
--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -1375,7 +1375,7 @@
         sys.argv[1:]).  Any errors result in a call to 'error()', which
         by default prints the usage message to stderr and calls
         sys.exit() with an error message.  On success returns a pair
-        (values, args) where 'values' is an Values instance (with all
+        (values, args) where 'values' is a Values instance (with all
         your option values) and 'args' is the list of arguments left
         over after parsing options.
         """
diff --git a/Lib/plat-irix5/flp.py b/Lib/plat-irix5/flp.py
index 13c926f..f06e7f8 100644
--- a/Lib/plat-irix5/flp.py
+++ b/Lib/plat-irix5/flp.py
@@ -329,7 +329,7 @@
 #################################################################
 
 #
-# External - Create a form an link to an instance variable.
+# External - Create a form and link to an instance variable.
 #
 def create_full_form(inst, (fdata, odatalist)):
     form = create_form(fdata)
diff --git a/Lib/plat-irix6/flp.py b/Lib/plat-irix6/flp.py
index 32e8b9d..14231cb 100644
--- a/Lib/plat-irix6/flp.py
+++ b/Lib/plat-irix6/flp.py
@@ -328,7 +328,7 @@
 #################################################################
 
 #
-# External - Create a form an link to an instance variable.
+# External - Create a form and link to an instance variable.
 #
 def create_full_form(inst, (fdata, odatalist)):
     form = create_form(fdata)
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Files.py b/Lib/plat-mac/lib-scriptpackages/Finder/Files.py
index ddbe1ba..0afdc04 100644
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Files.py
+++ b/Lib/plat-mac/lib-scriptpackages/Finder/Files.py
@@ -102,7 +102,7 @@
 files = file
 
 class internet_location_file(aetools.ComponentItem):
-    """internet location file - An file containing an internet location """
+    """internet location file - A file containing an internet location """
     want = 'inlf'
 class _Prop_location(aetools.NProperty):
     """location - the internet location """
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Processes_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Processes_Suite.py
index 9dcb85f..ff7be3c 100644
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Processes_Suite.py
+++ b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Processes_Suite.py
@@ -58,7 +58,7 @@
 application_processes = application_process
 
 class desk_accessory_process(aetools.ComponentItem):
-    """desk accessory process - A process launched from an desk accessory file """
+    """desk accessory process - A process launched from a desk accessory file """
     want = 'pcda'
 class _Prop_desk_accessory_file(aetools.NProperty):
     """desk accessory file - a reference to the desk accessory file from which this process was launched """
diff --git a/Lib/socket.py b/Lib/socket.py
index 614af29..437634c 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -549,7 +549,7 @@
     global default timeout setting returned by :func:`getdefaulttimeout`
     is used.  If *source_address* is set it must be a tuple of (host, port)
     for the socket to bind as a source address before making the connection.
-    An host of '' or port 0 tells the OS to use the default.
+    A host of '' or port 0 tells the OS to use the default.
     """
 
     host, port = address
diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py
index f4b8428..0e0196a 100644
--- a/Lib/sqlite3/test/factory.py
+++ b/Lib/sqlite3/test/factory.py
@@ -229,7 +229,7 @@
         self.assertEqual(row[0], "a\x00b")
 
     def CheckCustom(self):
-        # A custom factory should receive an str argument
+        # A custom factory should receive a str argument
         self.con.text_factory = lambda x: x
         row = self.con.execute("select value from test").fetchone()
         self.assertIs(type(row[0]), str)
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
index 72c9277..8b0a715 100644
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -73,7 +73,7 @@
     def CheckStatementFinalizationOnCloseDb(self):
         # pysqlite versions <= 2.3.3 only finalized statements in the statement
         # cache when closing the database. statements that were still
-        # referenced in cursors weren't closed an could provoke "
+        # referenced in cursors weren't closed and could provoke "
         # "OperationalError: Unable to close due to unfinalised statements".
         con = sqlite.connect(":memory:")
         cursors = []
diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py
index b1ef626..c7949fd 100644
--- a/Lib/test/test_binop.py
+++ b/Lib/test/test_binop.py
@@ -56,7 +56,7 @@
     den = property(_get_den, None)
 
     def __repr__(self):
-        """Convert a Rat to an string resembling a Rat constructor call."""
+        """Convert a Rat to a string resembling a Rat constructor call."""
         return "Rat(%d, %d)" % (self.__num, self.__den)
 
     def __str__(self):
@@ -78,7 +78,7 @@
         raise ValueError, "can't convert %s to int" % repr(self)
 
     def __long__(self):
-        """Convert a Rat to an long; self.den must be 1."""
+        """Convert a Rat to a long; self.den must be 1."""
         if self.__den == 1:
             return long(self.__num)
         raise ValueError, "can't convert %s to long" % repr(self)
diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py
index 2cb2c88..5101484 100644
--- a/Lib/test/test_cmd.py
+++ b/Lib/test/test_cmd.py
@@ -110,7 +110,7 @@
     5  12  19
     6  13
 
-    This is a interactive test, put some commands in the cmdqueue attribute
+    This is an interactive test, put some commands in the cmdqueue attribute
     and let it execute
     This test includes the preloop(), postloop(), default(), emptyline(),
     parseline(), do_help() functions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 57d5e06..efc40cf 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -47,7 +47,7 @@
         self.assertEqual(r.bytebuffer, "")
         self.assertEqual(r.charbuffer, u"")
 
-        # do the check again, this time using a incremental decoder
+        # do the check again, this time using an incremental decoder
         d = codecs.getincrementaldecoder(self.encoding)()
         result = u""
         for (c, partialresult) in zip(input.encode(self.encoding), partialresults):
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 4a341ed..4b27424 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -951,7 +951,7 @@
         HTTPException: message
     TestResults(failed=1, attempted=2)
 
-But in Python 2 the module path is not included, an therefore a test must look
+But in Python 2 the module path is not included, and therefore a test must look
 like the following test to succeed in Python 2. But that test will fail under
 Python 3.
 
diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py
index babcce9..cb2c45e 100644
--- a/Lib/test/test_extcall.py
+++ b/Lib/test/test_extcall.py
@@ -282,7 +282,7 @@
     >>> f(**x)
     1 2
 
-A obscure message:
+An obscure message:
 
     >>> def f(a, b):
     ...    pass
diff --git a/Lib/test/test_mutants.py b/Lib/test/test_mutants.py
index 69c381e..c70106d 100644
--- a/Lib/test/test_mutants.py
+++ b/Lib/test/test_mutants.py
@@ -4,7 +4,7 @@
 
 # From SF bug #422121:  Insecurities in dict comparison.
 
-# Safety of code doing comparisons has been an historical Python weak spot.
+# Safety of code doing comparisons has been a historical Python weak spot.
 # The problem is that comparison of structures written in C *naturally*
 # wants to hold on to things like the size of the container, or "the
 # biggest" containee so far, across a traversal of the container; but
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 6336a20..95bd26e 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -463,7 +463,7 @@
         self.assertEqual(os.path.abspath(sys.executable), sys.executable)
 
         # Issue #7774: Ensure that sys.executable is an empty string if argv[0]
-        # has been set to an non existent program name and Python is unable to
+        # has been set to a non existent program name and Python is unable to
         # retrieve the real program name
         import subprocess
         # For a normal installation, it should work without 'cwd'
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 212bd1a..ac14e66 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -876,7 +876,7 @@
     eventtype = staticmethod(threading.Event)
 
 class ConditionAsRLockTests(lock_tests.RLockTests):
-    # An Condition uses an RLock by default and exports its API.
+    # Condition uses an RLock by default and exports its API.
     locktype = staticmethod(threading.Condition)
 
 class ConditionTests(lock_tests.ConditionTests):
diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py
index e0e399c..3a2c0bf 100644
--- a/Lib/xmlrpclib.py
+++ b/Lib/xmlrpclib.py
@@ -358,7 +358,7 @@
 # tuple.
 #
 # @param value The time, given as an ISO 8601 string, a time
-#              tuple, or a integer time value.
+#              tuple, or an integer time value.
 
 def _strftime(value):
     if datetime:
@@ -1616,7 +1616,7 @@
         # magic method dispatcher
         return _Method(self.__request, name)
 
-    # note: to call a remote object with an non-standard name, use
+    # note: to call a remote object with a non-standard name, use
     # result getattr(server, "strange-python-name")(args)
 
     def __call__(self, attr):