Issue #27626: Spelling fixes in docs, comments and internal names

Based on patch by Ville Skyttä.
diff --git a/Demo/tix/samples/Balloon.py b/Demo/tix/samples/Balloon.py
index 576b4ed..0cd57c0 100644
--- a/Demo/tix/samples/Balloon.py
+++ b/Demo/tix/samples/Balloon.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/BtnBox.py b/Demo/tix/samples/BtnBox.py
index af2a2a8..d5e2e29 100644
--- a/Demo/tix/samples/BtnBox.py
+++ b/Demo/tix/samples/BtnBox.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/CmpImg.py b/Demo/tix/samples/CmpImg.py
index 8b33579..2fc513b 100644
--- a/Demo/tix/samples/CmpImg.py
+++ b/Demo/tix/samples/CmpImg.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/ComboBox.py b/Demo/tix/samples/ComboBox.py
index 9140987..8abcf69 100644
--- a/Demo/tix/samples/ComboBox.py
+++ b/Demo/tix/samples/ComboBox.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/Control.py b/Demo/tix/samples/Control.py
index 3a344c1..b486592 100644
--- a/Demo/tix/samples/Control.py
+++ b/Demo/tix/samples/Control.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/DirList.py b/Demo/tix/samples/DirList.py
index 5fd8c0d..054d1f8 100644
--- a/Demo/tix/samples/DirList.py
+++ b/Demo/tix/samples/DirList.py
@@ -2,7 +2,7 @@
 #
 #       $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py":  it must have a
diff --git a/Demo/tix/samples/DirTree.py b/Demo/tix/samples/DirTree.py
index 2e4fe0b..dfeadfb 100644
--- a/Demo/tix/samples/DirTree.py
+++ b/Demo/tix/samples/DirTree.py
@@ -2,7 +2,7 @@
 #
 #       $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py":  it must have a
diff --git a/Demo/tix/samples/NoteBook.py b/Demo/tix/samples/NoteBook.py
index 1e0da3e..96c0b0f 100644
--- a/Demo/tix/samples/NoteBook.py
+++ b/Demo/tix/samples/NoteBook.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/OptMenu.py b/Demo/tix/samples/OptMenu.py
index 1d39420..8e51a9d 100644
--- a/Demo/tix/samples/OptMenu.py
+++ b/Demo/tix/samples/OptMenu.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/PanedWin.py b/Demo/tix/samples/PanedWin.py
index 3efc731..13aeb5a 100644
--- a/Demo/tix/samples/PanedWin.py
+++ b/Demo/tix/samples/PanedWin.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/PopMenu.py b/Demo/tix/samples/PopMenu.py
index 32f3229..7028f69 100644
--- a/Demo/tix/samples/PopMenu.py
+++ b/Demo/tix/samples/PopMenu.py
@@ -2,7 +2,7 @@
 #
 #       $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/SHList1.py b/Demo/tix/samples/SHList1.py
index 7ca7b3e..51d005a 100644
--- a/Demo/tix/samples/SHList1.py
+++ b/Demo/tix/samples/SHList1.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/tix/samples/SHList2.py b/Demo/tix/samples/SHList2.py
index 17fd551..5dd51ff 100644
--- a/Demo/tix/samples/SHList2.py
+++ b/Demo/tix/samples/SHList2.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidget": it must have a
diff --git a/Demo/tix/samples/Tree.py b/Demo/tix/samples/Tree.py
index 9a7e481..af5e421 100644
--- a/Demo/tix/samples/Tree.py
+++ b/Demo/tix/samples/Tree.py
@@ -2,7 +2,7 @@
 #
 # $Id$
 #
-# Tix Demostration Program
+# Tix Demonstration Program
 #
 # This sample program is structured in such a way so that it can be
 # executed from the Tix demo program "tixwidgets.py": it must have a
diff --git a/Demo/turtle/tdemo_I_dontlike_tiltdemo.py b/Demo/turtle/tdemo_I_dontlike_tiltdemo.py
index c9e6e65..3851f55 100755
--- a/Demo/turtle/tdemo_I_dontlike_tiltdemo.py
+++ b/Demo/turtle/tdemo_I_dontlike_tiltdemo.py
@@ -3,7 +3,7 @@
 
      tdemo-I_dont_like_tiltdemo.py
 
-Demostrates
+Demonstrates
   (a) use of a tilted ellipse as
       turtle shape
   (b) stamping that shape
diff --git a/Doc/howto/sockets.rst b/Doc/howto/sockets.rst
index 2b08141..69abf78 100644
--- a/Doc/howto/sockets.rst
+++ b/Doc/howto/sockets.rst
@@ -110,7 +110,7 @@
 There's actually 3 general ways in which this loop could work - dispatching a
 thread to handle ``clientsocket``, create a new process to handle
 ``clientsocket``, or restructure this app to use non-blocking sockets, and
-mulitplex between our "server" socket and any active ``clientsocket``\ s using
+multiplex between our "server" socket and any active ``clientsocket``\ s using
 ``select``. More about that later. The important thing to understand now is
 this: this is *all* a "server" socket does. It doesn't send any data. It doesn't
 receive any data. It just produces "client" sockets. Each ``clientsocket`` is
diff --git a/Include/longobject.h b/Include/longobject.h
index 8be2345..4e33ff2 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -110,7 +110,7 @@
      example, if is_signed is 0 and there are more digits in the v than
      fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of
      being large enough to hold a sign bit.  OverflowError is set in this
-     case, but bytes holds the least-signficant n bytes of the true value.
+     case, but bytes holds the least-significant n bytes of the true value.
 */
 PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
 	unsigned char* bytes, size_t n,
diff --git a/Lib/ctypes/test/test_numbers.py b/Lib/ctypes/test/test_numbers.py
index d623465..ec42e96 100644
--- a/Lib/ctypes/test/test_numbers.py
+++ b/Lib/ctypes/test/test_numbers.py
@@ -76,7 +76,7 @@
             self.assertEqual(t(v).value, truth(v))
 
     def test_typeerror(self):
-        # Only numbers are allowed in the contructor,
+        # Only numbers are allowed in the constructor,
         # otherwise TypeError is raised
         for t in signed_types + unsigned_types + float_types:
             self.assertRaises(TypeError, t, "")
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index f983a6b..5650189 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -106,7 +106,7 @@
         self.assertEqual(alignment(XX), alignment(X))
         self.assertEqual(sizeof(XX), calcsize("3s 3s 0s"))
 
-    def test_emtpy(self):
+    def test_empty(self):
         # I had problems with these
         #
         # Although these are pathological cases: Empty Structures!
diff --git a/Lib/idlelib/CallTipWindow.py b/Lib/idlelib/CallTipWindow.py
index 90c2d7c..e63164b 100644
--- a/Lib/idlelib/CallTipWindow.py
+++ b/Lib/idlelib/CallTipWindow.py
@@ -9,7 +9,7 @@
 HIDE_SEQUENCES = ("<Key-Escape>", "<FocusOut>")
 CHECKHIDE_VIRTUAL_EVENT_NAME = "<<calltipwindow-checkhide>>"
 CHECKHIDE_SEQUENCES = ("<KeyRelease>", "<ButtonRelease>")
-CHECKHIDE_TIME = 100 # miliseconds
+CHECKHIDE_TIME = 100 # milliseconds
 
 MARK_RIGHT = "calltipwindowregion_right"
 
diff --git a/Lib/idlelib/ParenMatch.py b/Lib/idlelib/ParenMatch.py
index 19bad8c..47e10f3 100644
--- a/Lib/idlelib/ParenMatch.py
+++ b/Lib/idlelib/ParenMatch.py
@@ -9,7 +9,7 @@
 from idlelib.configHandler import idleConf
 
 _openers = {')':'(',']':'[','}':'{'}
-CHECK_DELAY = 100 # miliseconds
+CHECK_DELAY = 100 # milliseconds
 
 class ParenMatch:
     """Highlight matching parentheses
diff --git a/Lib/platform.py b/Lib/platform.py
index 63455ce..6e264f1 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -63,7 +63,7 @@
 #            though
 #    0.5.2 - fixed uname() to return '' instead of 'unknown' in all
 #            return values (the system uname command tends to return
-#            'unknown' instead of just leaving the field emtpy)
+#            'unknown' instead of just leaving the field empty)
 #    0.5.1 - included code for slackware dist; added exception handlers
 #            to cover up situations where platforms don't have os.popen
 #            (e.g. Mac) or fail on socket.gethostname(); fixed libc
diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_cookielib.py
index 5182bc0..f2dd972 100644
--- a/Lib/test/test_cookielib.py
+++ b/Lib/test/test_cookielib.py
@@ -346,7 +346,7 @@
 ##   comma-separated list, it'll be a headache to parse (at least my head
 ##   starts hurting every time I think of that code).
 ## - Expires: You'll get all sorts of date formats in the expires,
-##   including emtpy expires attributes ("expires="). Be as flexible as you
+##   including empty expires attributes ("expires="). Be as flexible as you
 ##   can, and certainly don't expect the weekday to be there; if you can't
 ##   parse it, just ignore it and pretend it's a session cookie.
 ## - Domain-matching: Netscape uses the 2-dot rule for _all_ domains, not
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index 3e88168..c81064d 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -329,7 +329,7 @@
         d.clear()
         self.assertEqual(len(d), 0)
         self.assertEqual(list(d), [])
-        d.clear()               # clear an emtpy deque
+        d.clear()               # clear an empty deque
         self.assertEqual(list(d), [])
 
     def test_remove(self):
diff --git a/Lib/test/test_structseq.py b/Lib/test/test_structseq.py
index daa12aa..75861fe 100644
--- a/Lib/test/test_structseq.py
+++ b/Lib/test/test_structseq.py
@@ -88,7 +88,7 @@
         class Exc(Exception):
             pass
 
-        # Devious code could crash structseqs' contructors
+        # Devious code could crash structseqs' constructors
         class C:
             def __getitem__(self, i):
                 raise Exc
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 0c23c96..8f46101 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -529,7 +529,7 @@
            between the two objects is more than the given delta.
 
            Note that decimal places (from zero) are usually not the same
-           as significant digits (measured from the most signficant digit).
+           as significant digits (measured from the most significant digit).
 
            If the two objects compare equal then they will automatically
            compare almost equal.
@@ -567,7 +567,7 @@
            between the two objects is less than the given delta.
 
            Note that decimal places (from zero) are usually not the same
-           as significant digits (measured from the most signficant digit).
+           as significant digits (measured from the most significant digit).
 
            Objects that are equal automatically fail.
         """
diff --git a/Misc/NEWS b/Misc/NEWS
index 5494aac..06f10c9 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -7975,7 +7975,7 @@
   mailbox.MH.get_message().
 
 - Issue #5585: Add the ability to call an initializer to
-  mulitiprocessing.manager so that users can install custom handlers/etc.
+  multiprocessing.manager so that users can install custom handlers/etc.
 
 - Issue #3551: Patch multiprocessing to raise a proper exception if the size of
   the object when writefile is called causes an ERROR_NO_SYSTEM_RESOURCES.  Added
@@ -10173,7 +10173,7 @@
   module is:
     from future_builtins import hex, oct
 
-- Issue #1600: Modifed PyOS_ascii_formatd to use at most 2 digit
+- Issue #1600: Modified PyOS_ascii_formatd to use at most 2 digit
   exponents for exponents with absolute value < 100.  Follows C99
   standard.  This is a change on Windows, which would use 3 digits.
   Also, added 'n' to the formats that PyOS_ascii_formatd understands,
diff --git a/Misc/cheatsheet b/Misc/cheatsheet
index d4eeda6..1e77543 100644
--- a/Misc/cheatsheet
+++ b/Misc/cheatsheet
@@ -434,7 +434,7 @@
     defaultVal, and adds k to map with value defaultVal. defaultVal is
     optional. When not provided and k is not in the map, None is returned and
     added to map.
-      (6) Raises a KeyError if the dictionary is emtpy.
+      (6) Raises a KeyError if the dictionary is empty.
       (7) While iterating over a dictionary, the values may be updated but
           the keys cannot be changed.
 
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index f12a7b2..421cdcc 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -366,7 +366,7 @@
 
 /*
   PyCStructType_Type - a meta type/class.  Creating a new class using this one as
-  __metaclass__ will call the contructor StructUnionType_new.  It replaces the
+  __metaclass__ will call the constructor StructUnionType_new.  It replaces the
   tp_dict member with a new instance of StgDict, and initializes the C
   accessible fields somehow.
 */
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 68285b8..f91501b 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1747,7 +1747,7 @@
 PyDoc_STRVAR(chain_from_iterable_doc,
 "chain.from_iterable(iterable) --> chain object\n\
 \n\
-Alternate chain() contructor taking a single iterable argument\n\
+Alternate chain() constructor taking a single iterable argument\n\
 that evaluates lazily.");
 
 static PyMethodDef chain_methods[] = {
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 3fc0e13..1929777 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -1640,7 +1640,7 @@
         return PyUnicode_FromString("");
 
     /* Get reason and encoding as strings, which they might not be if
-       they've been modified after we were contructed. */
+       they've been modified after we were constructed. */
     reason_str = PyObject_Str(uself->reason);
     if (reason_str == NULL)
         goto done;
@@ -1729,7 +1729,7 @@
         return PyUnicode_FromString("");
 
     /* Get reason and encoding as strings, which they might not be if
-       they've been modified after we were contructed. */
+       they've been modified after we were constructed. */
     reason_str = PyObject_Str(uself->reason);
     if (reason_str == NULL)
         goto done;
@@ -1830,7 +1830,7 @@
         return PyUnicode_FromString("");
 
     /* Get reason as a string, which it might not be if it's been
-       modified after we were contructed. */
+       modified after we were constructed. */
     reason_str = PyObject_Str(uself->reason);
     if (reason_str == NULL)
         goto done;
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 6427f42..ead8f28 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -556,10 +556,10 @@
         size_t i;
         const unsigned char* p = pendbyte;
         const int pincr = -incr;  /* search MSB to LSB */
-        const unsigned char insignficant = is_signed ? 0xff : 0x00;
+        const unsigned char insignificant = is_signed ? 0xff : 0x00;
 
         for (i = 0; i < n; ++i, p += pincr) {
-            if (*p != insignficant)
+            if (*p != insignificant)
                 break;
         }
         numsignificantbytes = n - i;
diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py
index 836f532..2764cec 100755
--- a/Tools/freeze/freeze.py
+++ b/Tools/freeze/freeze.py
@@ -159,7 +159,7 @@
     except getopt.error, msg:
         usage('getopt error: ' + str(msg))
 
-    # proces option arguments
+    # process option arguments
     for o, a in opts:
         if o == '-h':
             print __doc__
diff --git a/Tools/scripts/redemo.py b/Tools/scripts/redemo.py
index 2b5ade4..60dba5e 100755
--- a/Tools/scripts/redemo.py
+++ b/Tools/scripts/redemo.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-"""Basic regular expression demostration facility (Perl style syntax)."""
+"""Basic regular expression demonstration facility (Perl style syntax)."""
 
 from Tkinter import *
 import re