merge 2.7.13 release branch
diff --git a/Doc/library/_winreg.rst b/Doc/library/_winreg.rst
index 3d9042c..a87cb9c 100644
--- a/Doc/library/_winreg.rst
+++ b/Doc/library/_winreg.rst
@@ -1,5 +1,5 @@
-:mod:`_winreg` -- Windows registry access
-=========================================
+:mod:`_winreg` --- Windows registry access
+==========================================
 
 .. module:: _winreg
    :platform: Windows
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index c4307b5..f93e945 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -1,5 +1,5 @@
-:mod:`importlib` -- Convenience wrappers for :func:`__import__`
-===============================================================
+:mod:`importlib` --- Convenience wrappers for :func:`__import__`
+================================================================
 
 .. module:: importlib
    :synopsis: Convenience wrappers for __import__
diff --git a/Doc/library/msvcrt.rst b/Doc/library/msvcrt.rst
index 87b8166..5e6d523 100644
--- a/Doc/library/msvcrt.rst
+++ b/Doc/library/msvcrt.rst
@@ -1,6 +1,6 @@
 
-:mod:`msvcrt` -- Useful routines from the MS VC++ runtime
-=========================================================
+:mod:`msvcrt` --- Useful routines from the MS VC++ runtime
+==========================================================
 
 .. module:: msvcrt
    :platform: Windows
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 9f5255a..be28032 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1551,9 +1551,7 @@
 
 (2)
    The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on whether
-   the ``'x'`` or ``'X'`` format was used) to be inserted between left-hand padding
-   and the formatting of the number if the leading character of the result is not
-   already a zero.
+   the ``'x'`` or ``'X'`` format was used) to be inserted before the first digit.
 
 (3)
    The alternate form causes the result to always contain a decimal point, even if
diff --git a/Doc/tools/templates/indexsidebar.html b/Doc/tools/templates/indexsidebar.html
index d93021d..9e5c71f 100644
--- a/Doc/tools/templates/indexsidebar.html
+++ b/Doc/tools/templates/indexsidebar.html
@@ -2,8 +2,9 @@
 <p><a href="{{ pathto('download') }}">{% trans %}Download these documents{% endtrans %}</a></p>
 <h3>{% trans %}Docs for other versions{% endtrans %}</h3>
 <ul>
-  <li><a href="https://docs.python.org/3.4/">{% trans %}Python 3.4 (stable){% endtrans %}</a></li>
-  <li><a href="https://docs.python.org/3.5/">{% trans %}Python 3.5 (in development){% endtrans %}</a></li>
+  <li><a href="https://docs.python.org/3.5/">{% trans %}Python 3.5 (stable){% endtrans %}</a></li>
+  <li><a href="https://docs.python.org/3.6/">{% trans %}Python 3.6 (pre-release){% endtrans %}</a></li>
+  <li><a href="https://docs.python.org/3.7/">{% trans %}Python 3.7 (in development){% endtrans %}</a></li>
   <li><a href="https://www.python.org/doc/versions/">{% trans %}Old versions{% endtrans %}</a></li>
 </ul>
 
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index 50b74d1..22c2a4f 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -1,8 +1,8 @@
 .. _tut-brieftourtwo:
 
-*********************************************
-Brief Tour of the Standard Library -- Part II
-*********************************************
+**********************************************
+Brief Tour of the Standard Library --- Part II
+**********************************************
 
 This second tour covers more advanced modules that support professional
 programming needs.  These modules rarely occur in small scripts.
diff --git a/Include/patchlevel.h b/Include/patchlevel.h
index ea30f8e..53daaf6 100644
--- a/Include/patchlevel.h
+++ b/Include/patchlevel.h
@@ -23,11 +23,11 @@
 #define PY_MAJOR_VERSION	2
 #define PY_MINOR_VERSION	7
 #define PY_MICRO_VERSION	13
-#define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_GAMMA
-#define PY_RELEASE_SERIAL	1
+#define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_FINAL
+#define PY_RELEASE_SERIAL	0
 
 /* Version as a string */
-#define PY_VERSION      	"2.7.13rc1"
+#define PY_VERSION      	"2.7.13+"
 /*--end constants--*/
 
 /* Subversion Revision number of this file (not of the repository). Empty
diff --git a/Lib/lib2to3/fixer_base.py b/Lib/lib2to3/fixer_base.py
index d437b96..2f50ad3 100644
--- a/Lib/lib2to3/fixer_base.py
+++ b/Lib/lib2to3/fixer_base.py
@@ -4,7 +4,6 @@
 """Base class for fixers (optional, but recommended)."""
 
 # Python imports
-import logging
 import itertools
 
 # Local imports
@@ -75,7 +74,6 @@
         The main refactoring tool should call this.
         """
         self.filename = filename
-        self.logger = logging.getLogger(filename)
 
     def match(self, node):
         """Returns match for a given parse tree node.
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 4325005..9a1fb67 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -400,20 +400,19 @@
     def test_replace_parent_in_sys_modules(self):
         dir_name = os.path.abspath(TESTFN)
         os.mkdir(dir_name)
-        try:
-            pkg_dir = os.path.join(dir_name, 'sa')
-            os.mkdir(pkg_dir)
-            with open(os.path.join(pkg_dir, '__init__.py'), 'w') as init_file:
-                init_file.write("import v1")
-            with open(os.path.join(pkg_dir, 'v1.py'), 'w') as v1_file:
-                v1_file.write("import sys;"
-                              "sys.modules['sa'] = sys.modules[__name__];"
-                              "import sa")
-            sys.path.insert(0, dir_name)
-            # a segfault means the test failed!
-            import sa
-        finally:
-            rmtree(dir_name)
+        self.addCleanup(rmtree, dir_name)
+        pkg_dir = os.path.join(dir_name, 'sa')
+        os.mkdir(pkg_dir)
+        with open(os.path.join(pkg_dir, '__init__.py'), 'w') as init_file:
+            init_file.write("import v1")
+        with open(os.path.join(pkg_dir, 'v1.py'), 'w') as v1_file:
+            v1_file.write("import sys;"
+                          "sys.modules['sa'] = sys.modules[__name__];"
+                          "import sa")
+        sys.path.insert(0, dir_name)
+        self.addCleanup(sys.path.pop, 0)
+        # a segfault means the test failed!
+        import sa
 
     def test_fromlist_type(self):
         with self.assertRaises(TypeError) as cm:
diff --git a/Misc/NEWS b/Misc/NEWS
index bb4c1d9..ce0e465 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2,6 +2,17 @@
 Python News
 +++++++++++
 
+What's New in Python 2.7.14?
+============================
+
+*Release date: XXXX-XX-XX*
+
+Core and Builtins
+-----------------
+
+Library
+-------
+
 What's New in Python 2.7.13
 ===========================
 
@@ -21,6 +32,9 @@
 Core and Builtins
 -----------------
 
+- Issue #5322: Fixed setting __new__ to a PyCFunction inside Python code.
+  Original patch by Andreas Stührk.
+
 - Issue #28847: dumbdbm no longer writes the index file in when it is not
   changed and supports reading read-only files.