Re: What to do about sagemath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 17, 2018 at 10:13 PM Jerry James <loganjerry@xxxxxxxxx> wrote:
> I think I'm past the cython problems now.  There are a few more issues to fix, but I think I made a lot of progress over the last few days.  Unfortunately, I now have to drop the ball and do some traveling for the rest of this week.  I'll try to move forward again next Monday, but until then, if anybody feels motivated to work on the remaining issues, I'll attach what I have so far (modified spec file and a few new patches).


Argh.  Hit the wrong button.  Here are the rest of the patches.
-- 
Jerry James
http://www.jamezone.org/
--- src/setup.py.orig	2018-10-16 09:07:30.086993782 -0600
+++ src/setup.py	2018-10-16 09:10:20.586710425 -0600
@@ -387,6 +387,9 @@ class sage_build_cython(Command):
         with open(self._version_file, 'w') as f:
             f.write(self._version_stamp)
 
+        # Remove buildroot paths from the generated files
+        subprocess.run(["find", "build/cythonized/sage", "-type", "f", "-exec", "sed", "-i", "s|@@BUILDROOT@@||g", "{}", "+"], check=True)
+
         # Finally, copy relevant cythonized files from build/cythonized
         # tree into the build-lib tree
         for (dst_dir, src_files) in self.get_cythonized_package_files():
--- build/pkgs/sagenb/src/sagenb/misc/sphinxify.py.orig	2018-10-17 09:42:45.846827860 -0600
+++ build/pkgs/sagenb/src/sagenb/misc/sphinxify.py	2018-10-17 14:39:25.730482157 -0600
@@ -133,7 +133,7 @@ def sphinxify(docstring, format='html'):
         #    "/media/...path.../blah.png"
         # to
         #    "/doc/static/reference/media/...path.../blah.png"
-        output = re.sub("""src=['"](/?\.\.)*/?media/([^"']*)['"]""",
+        output = re.sub("""src=['"](/?\\.\\.)*/?media/([^"']*)['"]""",
                         'src="/doc/static/reference/media/\\2"',
                         output)
         # Remove spurious \(, \), \[, \].
--- build/pkgs/sagenb/src/sagenb/misc/support.py.orig	2018-10-17 09:23:38.909683823 -0600
+++ build/pkgs/sagenb/src/sagenb/misc/support.py	2018-10-17 14:39:58.178063650 -0600
@@ -550,7 +550,7 @@ try:
             return args[0].__getattribute__(str(self))(*args[1:], **kwds)
 
     def automatic_name_eval(s, globals, max_names=10000):
-        """
+        r"""
         Exec the string ``s`` in the scope of the ``globals``
         dictionary, and if any :exc:`NameError`\ s are raised, try to
         fix them by defining the variable that caused the error to be
--- build/pkgs/sagenb/src/sagenb/notebook/cell.py.orig	2018-10-17 09:40:11.817824538 -0600
+++ build/pkgs/sagenb/src/sagenb/notebook/cell.py	2018-10-17 14:40:47.618425972 -0600
@@ -441,7 +441,7 @@ class Cell_generic(object):
         return isinstance(self, Cell)
 
     def is_auto_cell(self):
-        """
+        r"""
         Returns whether this is an automatically evaluated generic
         cell.  This is always false for :class:`Cell_generic`\ s and
         :class:`TextCell`\ s.
@@ -647,7 +647,7 @@ class TextCell(Cell_generic):
         return self._text
 
     def set_cell_output_type(self, typ='wrap'):
-        """
+        r"""
         Sets this text cell's output type.  This does nothing for
         :class:`TextCell`\ s.
 
@@ -1320,8 +1320,8 @@ class Cell(Cell_generic):
         if len(s) == 0:
             return False
         s = s[0]
-        return bool(re.search('(?<!\w)interact\s*\(.*\).*', s) or
-                    re.search('\s*@\s*interact', s))
+        return bool(re.search(r'(?<!\w)interact\s*\(.*\).*', s) or
+                    re.search(r'\s*@\s*interact', s))
 
     def is_interacting(self):
         r"""
@@ -1344,7 +1344,7 @@ class Cell(Cell_generic):
         return hasattr(self, 'interact')
 
     def stop_interacting(self):
-        """
+        r"""
         Stops :func:`sagenb.notebook.interact.interact`\ ion for this
         compute cell.
 
--- build/pkgs/sagenb/src/sagenb/notebook/worksheet.py.orig	2018-05-22 10:01:48.000000000 -0600
+++ build/pkgs/sagenb/src/sagenb/notebook/worksheet.py	2018-10-17 14:41:08.634154908 -0600
@@ -61,8 +61,8 @@ from flask_babel import gettext, lazy_ge
 _ = gettext
 
 # Set some constants that will be used for regular expressions below.
-whitespace = re.compile('\s')  # Match any whitespace character
-non_whitespace = re.compile('\S')
+whitespace = re.compile(r'\s')  # Match any whitespace character
+non_whitespace = re.compile(r'\S')
 
 # The file to which the Sage code that will be evaluated is written.
 CODE_PY = "___code___.py"
--- src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py	2018-10-16 14:07:04.350588129 -0600
@@ -1670,7 +1670,7 @@ class QuiverMutationType_Irreducible(Qui
 
     @cached_method
     def class_size(self):
-        """
+        r"""
         If it is known, the size of the mutation class of all quivers
         which are mutation equivalent to the standard quiver of
         ``self`` (up to isomorphism) is returned.
@@ -2370,7 +2370,7 @@ def _is_mutation_type(data):
         return False
 
 def _mutation_type_error(data):
-    """
+    r"""
     Output an error message because data which is not a valid quiver mutation
     type has been passed to QuiverMutationType.
 
@@ -2391,7 +2391,7 @@ def _mutation_type_error(data):
     return_str  = str(data) + ' is not a valid quiver mutation type'
     return_str += '\n            Finite types have the form [ \'?\', n ] for type ? and rank n'
     return_str += '\n            Affine type A has the form [ \'A\', [ i, j ], 1 ] for rank i+j'
-    return_str += '\n            Affine type ? has the form [ \'?\', k, \pm 1 ] for rank k+1'
+    return_str += '\n            Affine type ? has the form [ \'?\', k, \\pm 1 ] for rank k+1'
     return_str += '\n            Elliptic type ? has the form [ \'?\', k, [i, j] ] (1 <= i,j <= 3) for rank k+2'
     return_str += '\n            For correct syntax in other types, please consult the documentation.'
 
--- src/sage/combinat/cluster_algebra_quiver/quiver.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/cluster_algebra_quiver/quiver.py	2018-10-16 14:05:40.063633152 -0600
@@ -1514,7 +1514,7 @@ class ClusterQuiver(SageObject):
 
         if show_sequence:
             def _plot_arrow( v, k, center=(0,0) ):
-                return text("$\longleftrightarrow$",(center[0],center[1]), fontsize=25) + text("$\mu_"+str(v)+"$",(center[0],center[1]+0.15), fontsize=15) \
+                return text("$\\longleftrightarrow$",(center[0],center[1]), fontsize=25) + text("$\\mu_"+str(v)+"$",(center[0],center[1]+0.15), fontsize=15) \
                     + text("$"+str(k)+"$",(center[0],center[1]-0.2), fontsize=15)
             plot_sequence = [ quiver_sequence[i].plot( circular=True, center=(i*width_factor,0) ) for i in range(len(quiver_sequence)) ]
             arrow_sequence = [ _plot_arrow( sequence[i],i+1,center=((i+0.5)*width_factor,0) ) for i in range(len(sequence)) ]
--- src/sage/combinat/crystals/alcove_path.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/crystals/alcove_path.py	2018-10-16 13:53:44.959493985 -0600
@@ -381,7 +381,7 @@ class CrystalOfAlcovePaths(UniqueReprese
             return self.element_class(self, tuple(sorted([lambda_chain[i] for i in data])))
 
     def vertices(self):
-        """
+        r"""
         Return a list of all the vertices of the crystal.
 
         The vertices are represented as lists of integers recording the folding
@@ -389,7 +389,7 @@ class CrystalOfAlcovePaths(UniqueReprese
 
         One can compute all vertices of the crystal by finding all the
         admissible subsets of the `\lambda`-chain  (see method
-        is_admissible, for definition).  We use the breath first
+        is_admissible, for definition).  We use the breadth first
         search algorithm.
 
         .. WARNING::
--- src/sage/combinat/crystals/catalog_infinity_crystals.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/crystals/catalog_infinity_crystals.py	2018-10-16 14:08:46.747318572 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 Catalog Of Crystal Models For `B(\infty)`
 
 We currently have the following models:
--- src/sage/combinat/crystals/generalized_young_walls.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/crystals/generalized_young_walls.py	2018-10-16 13:55:00.270561746 -0600
@@ -433,7 +433,7 @@ class GeneralizedYoungWall(Combinatorial
         else:
             s += "\\begin{tikzpicture}[baseline=5,scale=.45] \n \\foreach \\x [count=\\s from 0] in \n"
             s += "{" + ','.join("{" + ','.join( str(i) for i in r ) + "}" for r in self.data ) + "} \n"
-            s += "{\\foreach \\y [count=\\t from 0] in \\x {  \\node[font=\\scriptsize] at (-\\t,\\s) {$\\y$}; \n \draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5);  } \n \draw[-,thick] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n"
+            s += "{\\foreach \\y [count=\\t from 0] in \\x {  \\node[font=\\scriptsize] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5);  } \n \\draw[-,thick] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n"
         return s
 
     def _latex_(self):
@@ -452,7 +452,7 @@ class GeneralizedYoungWall(Combinatorial
         else:
             s += "\\begin{tikzpicture}[baseline=5,scale=.25] \\foreach \\x [count=\\s from 0] in \n"
             s += "{" + ','.join("{" + ','.join( str(i) for i in r ) + "}" for r in self.data ) + "} \n"
-            s += "{\\foreach \\y [count=\\t from 0] in \\x {  \\node[font=\\tiny] at (-\\t,\\s) {$\\y$}; \n \draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5);  } \n \draw[-] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n"
+            s += "{\\foreach \\y [count=\\t from 0] in \\x {  \\node[font=\\tiny] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5);  } \n \\draw[-] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n"
         return s
 
     def weight(self, root_lattice=False):
--- src/sage/combinat/crystals/infinity_crystals.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/crystals/infinity_crystals.py	2018-10-16 14:10:20.043161850 -0600
@@ -249,7 +249,7 @@ class InfinityCrystalOfTableaux(CrystalO
 
     @cached_method
     def module_generator(self):
-        """
+        r"""
         Return the module generator (or highest weight element) of ``self``.
 
         The module generator is the unique tableau of shape `(n, n-1, \ldots,
@@ -622,7 +622,7 @@ class InfinityCrystalOfTableauxTypeD(Inf
 
     @cached_method
     def module_generator(self):
-        """
+        r"""
         Return the module generator (or highest weight element) of ``self``.
 
         The module generator is the unique tableau of shape `(n-1, \ldots, 2,
--- src/sage/combinat/crystals/kac_modules.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/crystals/kac_modules.py	2018-10-16 14:08:08.083797937 -0600
@@ -156,10 +156,10 @@ class CrystalOfOddNegativeRoots(UniqueRe
                 sage: latex(mg.f_string([0,-1,0]))
                 \{-e_{-2}+e_{1}, -e_{-1}+e_{1}\}
             """
-            return ('\{'
+            return ('\\{'
                     + ", ".join("-e_{{{}}}+e_{{{}}}".format(*i)
                                 for i in sorted(self.value))
-                    + '\}')
+                    + '\\}')
 
         def e(self, i):
             r"""
@@ -639,9 +639,9 @@ class CrystalOfKacModule(UniqueRepresent
                 }
             """
             from sage.misc.latex import latex
-            return " \otimes ".join([latex(self.value[0]),
-                                     latex_dual(self.value[1]),
-                                     latex(self.value[2])])
+            return " \\otimes ".join([latex(self.value[0]),
+                                      latex_dual(self.value[1]),
+                                      latex(self.value[2])])
 
         def e(self, i):
             r"""
--- src/sage/combinat/crystals/kirillov_reshetikhin.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/crystals/kirillov_reshetikhin.py	2018-10-16 13:52:57.456082001 -0600
@@ -354,7 +354,7 @@ def KirillovReshetikhinCrystal(cartan_ty
     raise ValueError("invalid model")
 
 def KashiwaraNakashimaTableaux(cartan_type, r, s):
-    """
+    r"""
     Return the Kashiwara-Nakashima model for the Kirillov-Reshetikhin crystal
     `B^{r,s}` in the given type.
 
@@ -867,7 +867,7 @@ class KR_type_vertical(KirillovReshetikh
 
     @cached_method
     def promotion(self):
-        """
+        r"""
         Specifies the promotion operator used to construct the affine
         type `D_n^{(1)}` etc. crystal.
 
@@ -971,7 +971,7 @@ class KR_type_vertical(KirillovReshetikh
         return self.promotion_on_highest_weight_vector
 
     def from_highest_weight_vector_to_pm_diagram(self, b):
-        """
+        r"""
         This gives the bijection between an element ``b`` in the classical
         decomposition of the KR crystal that is `{2, 3, \ldots, n}`-highest
         weight and `\pm` diagrams.
@@ -1002,7 +1002,7 @@ class KR_type_vertical(KirillovReshetikh
         return PMDiagram([self.r(), self.s(), outer, inter, inner], from_shapes=True)
 
     def from_pm_diagram_to_highest_weight_vector(self, pm):
-        """
+        r"""
         This gives the bijection between a `\pm` diagram and an element
         ``b`` in the classical decomposition of the KR crystal that
         is `{2, 3, \ldots, n}`-highest weight.
@@ -2457,7 +2457,7 @@ class KR_type_Cn(KirillovReshetikhinGene
         return CrystalOfTableaux(self.cartan_type().classical(), shape = [self.s()]*self.r() )
 
     def from_highest_weight_vector_to_pm_diagram(self, b):
-        """
+        r"""
         This gives the bijection between an element ``b`` in the classical
         decomposition of the KR crystal that is `{2,3,..,n}`-highest weight
         and `\pm` diagrams.
@@ -2485,7 +2485,7 @@ class KR_type_Cn(KirillovReshetikhinGene
         return PMDiagram([self.r(), self.s(), outer, inter, inner], from_shapes=True)
 
     def from_pm_diagram_to_highest_weight_vector(self, pm):
-        """
+        r"""
         This gives the bijection between a `\pm` diagram and an element ``b``
         in the classical decomposition of the KR crystal that is
         `\{2,3,..,n\}`-highest weight.
@@ -3473,7 +3473,7 @@ class KR_type_D_tri1(KirillovReshetikhin
 #####################################################################
 
 class PMDiagram(CombinatorialObject):
-    """
+    r"""
     Class of `\pm` diagrams. These diagrams are in one-to-one bijection with
     `X_{n-1}` highest weight vectors in an `X_n` highest weight crystal
     `X=B,C,D`. See Section 4.1 of [Schilling08]_.
@@ -3552,7 +3552,7 @@ class PMDiagram(CombinatorialObject):
         self.width = sum(self._list)
 
     def _repr_(self):
-        """
+        r"""
         Turning on pretty printing allows to display the `\pm` diagram as a
         tableau with the `+` and `-` displayed.
 
@@ -3632,7 +3632,7 @@ class PMDiagram(CombinatorialObject):
         return Partition(list(reversed(t)))
 
     def outer_shape(self):
-        """
+        r"""
         Return the outer shape of the `\pm` diagram
 
         EXAMPLES::
@@ -3687,7 +3687,7 @@ class PMDiagram(CombinatorialObject):
         return Partition(p)
 
     def heights_of_minus(self):
-        """
+        r"""
         Return a list with the heights of all minus in the `\pm` diagram.
 
         EXAMPLES::
@@ -3707,7 +3707,7 @@ class PMDiagram(CombinatorialObject):
         return heights
 
     def heights_of_addable_plus(self):
-        """
+        r"""
         Return a list with the heights of all addable plus in the `\pm` diagram.
 
         EXAMPLES::
--- src/sage/combinat/designs/bibd.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/designs/bibd.py	2018-10-17 13:42:27.762508102 -0600
@@ -764,7 +764,7 @@ def _relabel_bibd(B,n,p=None):
     return [[d[x] for x in X] for X in B]
 
 def PBD_4_5_8_9_12(v, check=True):
-    """
+    r"""
     Return a `(v,\{4,5,8,9,12\})`-PBD on `v` elements.
 
     A `(v,\{4,5,8,9,12\})`-PBD exists if and only if `v\equiv 0,1 \pmod 4`. The
--- src/sage/combinat/designs/block_design.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/designs/block_design.py	2018-10-17 13:42:55.866146771 -0600
@@ -1038,7 +1038,7 @@ def Hadamard3Design(n):
 
     REFERENCES:
 
-    .. [CvL] \P. Cameron, J. H. van Lint, Designs, graphs, codes and
+    .. [CvL] \\P. Cameron, J. H. van Lint, Designs, graphs, codes and
       their links, London Math. Soc., 1991.
     """
     if n == 1 or n == 4:
--- src/sage/combinat/designs/database.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/designs/database.py	2018-10-17 13:43:50.923438898 -0600
@@ -3123,7 +3123,7 @@ DF = {
 
 # Create the list of DF for the documentation
 _all_l = sorted(set(l for v,k,l in DF.keys()))
-LIST_OF_DF = "\n".join("    - `\lambda={}`:\n       ".format(l) +
+LIST_OF_DF = "\n".join("    - `\\lambda={}`:\n       ".format(l) +
                        ", ".join("`({},{},{})`".format(v,k,l) for v,k,_ in sorted(DF.keys()) if _ == l)
                        for l in _all_l)
 
@@ -4043,7 +4043,7 @@ DM = {
 
 # Create the list of DM for the documentation
 _all_l = sorted(set(l for v,l in DM.keys()))
-LIST_OF_DM = "\n".join("    - `\lambda={}`:\n       ".format(l)+
+LIST_OF_DM = "\n".join("    - `\\lambda={}`:\n       ".format(l)+
                        ", ".join("`({},{},{})`".format(v,k,l) for (v,_),(k,__) in sorted(DM.items()) if _ == l)
                        for l in _all_l)
 
@@ -4590,7 +4590,7 @@ BIBD_constructions = {
 
 # Create the list of DF for the documentation
 _all_l = sorted(set(l for v,k,l in BIBD_constructions.keys()))
-LIST_OF_BIBD = "\n".join("    - `\lambda={}`:\n       ".format(l) +
+LIST_OF_BIBD = "\n".join("    - `\\lambda={}`:\n       ".format(l) +
                        ", ".join("`({},{},{})`".format(v,k,l) for v,k,_ in sorted(BIBD_constructions) if _ == l)
                        for l in _all_l)
 
--- src/sage/combinat/matrices/hadamard_matrix.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/matrices/hadamard_matrix.py	2018-10-17 13:45:24.160240151 -0600
@@ -89,7 +89,7 @@ def normalise_hadamard(H):
     return H
 
 def hadamard_matrix_paleyI(n, normalize=True):
-    """
+    r"""
     Implements the Paley type I construction.
 
     The Paley type I case corresponds to the case `p \cong 3 \mod{4}` for a
@@ -155,7 +155,7 @@ def hadamard_matrix_paleyI(n, normalize=
     return H
 
 def hadamard_matrix_paleyII(n):
-    """
+    r"""
     Implements the Paley type II construction.
 
     The Paley type II case corresponds to the case `p \cong 1 \mod{4}` for a
--- src/sage/combinat/matrices/latin.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/matrices/latin.py	2018-10-17 13:46:31.176378532 -0600
@@ -1333,7 +1333,7 @@ def genus(T1, T2):
     return (len(t1.to_cycles()) + len(t2.to_cycles()) + len(t3.to_cycles()) - T1.nr_filled_cells() - 2) // (-2)
 
 def tau123(T1, T2):
-    """
+    r"""
     Compute the tau_i representation for a bitrade (T1, T2). See the
     functions tau1, tau2, and tau3 for the mathematical definitions.
 
@@ -2332,7 +2332,7 @@ def group_to_LatinSquare(G):
 
 
 def alternating_group_bitrade_generators(m):
-    """
+    r"""
     Construct generators a, b, c for the alternating group on 3m+1
     points, such that a\*b\*c = 1.
 
@@ -2464,7 +2464,7 @@ def p3_group_bitrade_generators(p):
 
 
 def check_bitrade_generators(a, b, c):
-    """
+    r"""
     Three group elements a, b, c will generate a bitrade if a\*b\*c = 1
     and the subgroups a, b, c intersect (pairwise) in just the
     identity.
--- src/sage/combinat/ncsf_qsym/ncsf.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/ncsf_qsym/ncsf.py	2018-10-17 13:47:23.856701218 -0600
@@ -2416,7 +2416,7 @@ class NonCommutativeSymmetricFunctions(U
                 return T.sum_of_monomials( (C(j), C(i-j)) for j in range(0,i+1) )
 
     class MultiplicativeBasesOnPrimitiveElements(Category_realization_of_parent):
-        """
+        r"""
         Category of multiplicative bases of the non-commutative symmetric
         functions whose generators are primitive elements.
 
--- src/sage/combinat/ncsf_qsym/qsym.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/ncsf_qsym/qsym.py	2018-10-17 13:49:24.551149459 -0600
@@ -2730,7 +2730,7 @@ class QuasiSymmetricFunctions(UniqueRepr
                                                          for i in range(0,len(compo)+1))
 
         def product_on_basis(self, I, J):
-            """
+            r"""
             The product on Essential basis elements.
 
             The product of the basis elements indexed by two compositions
@@ -3363,7 +3363,7 @@ class QuasiSymmetricFunctions(UniqueRepr
             self._M_inverse_transition_matrices = {}
 
         def _precompute_cache(self, n, to_self_cache, from_self_cache, transition_matrices, inverse_transition_matrices, from_self_gen_function):
-            """
+            r"""
             Compute the transition matrices between ``self`` and the
             monomial basis in the homogeneous components of degree `n`.
             The results are not returned, but rather stored in the caches.
--- src/sage/combinat/ncsym/bases.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/ncsym/bases.py	2018-10-17 13:50:35.012243545 -0600
@@ -474,7 +474,7 @@ class NCSymBases(Category_realization_of
 
         @lazy_attribute
         def internal_coproduct(self):
-            """
+            r"""
             Compute the internal coproduct of ``self``.
 
             If :meth:`internal_coproduct_on_basis()` is available, construct
@@ -660,7 +660,7 @@ class NCSymBases(Category_realization_of
                                         for A, coeff in m(self))
 
         def internal_coproduct(self):
-            """
+            r"""
             Return the internal coproduct of ``self``.
 
             The internal coproduct is defined on the power sum basis as
@@ -685,7 +685,7 @@ class NCSymBases(Category_realization_of
             return self.parent().internal_coproduct(self)
 
         def omega(self):
-            """
+            r"""
             Return the involution `\omega` applied to ``self``.
 
             The involution `\omega` is defined by
--- src/sage/combinat/ncsym/dual.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/ncsym/dual.py	2018-10-17 13:51:03.955871412 -0600
@@ -346,7 +346,7 @@ class SymmetricFunctionsNonCommutingVari
             return sum(coeff * y[I] for (I, coeff) in x)
 
         def sum_of_partitions(self, la):
-            """
+            r"""
             Return the sum over all sets partitions whose shape is ``la``,
             scaled by `\prod_i m_i!` where `m_i` is the multiplicity
             of `i` in ``la``.
--- src/sage/combinat/ncsym/ncsym.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/ncsym/ncsym.py	2018-10-17 13:52:41.380618813 -0600
@@ -425,7 +425,7 @@ class SymmetricFunctionsNonCommutingVari
                                  remove_zeros=False)
 
         def from_symmetric_function(self, f):
-            """
+            r"""
             Return the image of the symmetric function ``f`` in ``self``.
 
             This is performed by converting to the monomial basis and
@@ -1270,7 +1270,7 @@ class SymmetricFunctionsNonCommutingVari
 
         @cached_method
         def _p_to_m_on_basis(self, A):
-            """
+            r"""
             Return `\mathbf{p}_A` in terms of the monomial basis.
 
             INPUT:
@@ -1295,7 +1295,7 @@ class SymmetricFunctionsNonCommutingVari
 
         @cached_method
         def _p_to_e_on_basis(self, A):
-            """
+            r"""
             Return `\mathbf{p}_A` in terms of the elementary basis.
 
             INPUT:
@@ -1323,7 +1323,7 @@ class SymmetricFunctionsNonCommutingVari
 
         @cached_method
         def _p_to_h_on_basis(self, A):
-            """
+            r"""
             Return `\mathbf{p}_A` in terms of the homogeneous basis.
 
             INPUT:
@@ -1351,7 +1351,7 @@ class SymmetricFunctionsNonCommutingVari
 
         @cached_method
         def _p_to_x_on_basis(self, A):
-            """
+            r"""
             Return `\mathbf{p}_A` in terms of the `\mathbf{x}` basis.
 
             INPUT:
@@ -1433,7 +1433,7 @@ class SymmetricFunctionsNonCommutingVari
             return self.tensor_square().sum_of_monomials(L1 + L2)
 
         def internal_coproduct_on_basis(self, A):
-            """
+            r"""
             Return the internal coproduct of a powersum basis element.
 
             The internal coproduct is defined by
@@ -1675,7 +1675,7 @@ class SymmetricFunctionsNonCommutingVari
 
         @cached_method
         def _cp_to_m_on_basis(self, A):
-            """
+            r"""
             Return `\mathbf{cp}_A` in terms of the monomial basis.
 
             INPUT:
@@ -1702,7 +1702,7 @@ class SymmetricFunctionsNonCommutingVari
     cp = coarse_powersum
 
     def q(self):
-        """
+        r"""
         Old name for the `\mathbf{cp}`-basis. Deprecated in :trac:`18371`.
 
         EXAMPLES::
@@ -1759,7 +1759,7 @@ class SymmetricFunctionsNonCommutingVari
 
         @cached_method
         def _x_to_p_on_basis(self, A):
-            """
+            r"""
             Return `\mathbf{x}_A` in terms of the powersum basis.
 
             INPUT:
--- src/sage/combinat/posets/hasse_diagram.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/posets/hasse_diagram.py	2018-10-17 13:54:04.419551179 -0600
@@ -123,7 +123,7 @@ class HasseDiagram(DiGraph):
         return self.topological_sort_generator()
 
     def greedy_linear_extensions_iterator(self):
-        """
+        r"""
         Return an iterator over greedy linear extensions of the Hasse diagram.
 
         A linear extension `[e_1, e_2, \ldots, e_n]` is *greedy* if for
@@ -174,7 +174,7 @@ class HasseDiagram(DiGraph):
         return greedy_rec(self, [])
 
     def supergreedy_linear_extensions_iterator(self):
-        """
+        r"""
         Return an iterator over supergreedy linear extensions of the Hasse diagram.
 
         A linear extension `[e_1, e_2, \ldots, e_n]` is *supergreedy* if,
@@ -627,7 +627,7 @@ class HasseDiagram(DiGraph):
         return self._intervals[x][y]
 
     def interval(self, x, y):
-        """
+        r"""
         Return a list of the elements `z` of ``self`` such that
         `x \leq z \leq y`. The order is that induced by the
         ordering in ``self.linear_extension``.
@@ -1041,7 +1041,7 @@ class HasseDiagram(DiGraph):
         return - self.lequal_matrix()*self.moebius_function_matrix().transpose()
 
     def order_filter(self, elements):
-        """
+        r"""
         Return the order filter generated by a list of elements.
 
         `I` is an order filter if, for any `x` in `I` and `y` such that
@@ -1068,7 +1068,7 @@ class HasseDiagram(DiGraph):
         return self.order_filter([i])
 
     def order_ideal(self, elements):
-        """
+        r"""
         Return the order ideal generated by a list of elements.
 
         `I` is an order ideal if, for any `x` in `I` and `y` such that
@@ -2832,7 +2832,7 @@ class HasseDiagram(DiGraph):
         return cong
 
     def find_nontrivial_congruence(self):
-        """
+        r"""
         Return a pair that generates non-trivial congruence or
         ``None`` if there is not any.
 
--- src/sage/combinat/posets/lattices.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/posets/lattices.py	2018-10-17 13:55:49.146204707 -0600
@@ -349,7 +349,7 @@ class FiniteMeetSemilattice(FinitePoset)
         return self.upper_covers(self.bottom())
 
     def pseudocomplement(self, element):
-        """
+        r"""
         Return the pseudocomplement of ``element``, if it exists.
 
         The (meet-)pseudocomplement is the greatest element whose
@@ -1955,7 +1955,7 @@ class FiniteLatticePoset(FiniteMeetSemil
                 self.join(x, element) == self.top()]
 
     def is_pseudocomplemented(self, certificate=False):
-        """
+        r"""
         Return ``True`` if the lattice is pseudocomplemented, and ``False``
         otherwise.
 
@@ -2081,7 +2081,7 @@ class FiniteLatticePoset(FiniteMeetSemil
         return True
 
     def skeleton(self):
-        """
+        r"""
         Return the skeleton of the lattice.
 
         The lattice is expected to be pseudocomplemented.
@@ -2670,7 +2670,7 @@ class FiniteLatticePoset(FiniteMeetSemil
         return False
 
     def is_supersolvable(self, certificate=False):
-        """
+        r"""
         Return ``True`` if the lattice is supersolvable, and
         ``False`` otherwise.
 
@@ -4492,12 +4492,12 @@ class FiniteLatticePoset(FiniteMeetSemil
         return result
 
     def congruence(self, S):
-        """
+        r"""
         Return the congruence generated by set of sets `S`.
 
         A congruence of a lattice is an equivalence relation `\cong` that is
         compatible with meet and join; i.e. if `a_1 \cong a_2` and
-        `b_1 \cong b_2`, then `(a_1 \\vee b_1) \cong (a_2 \\vee b_2)` and
+        `b_1 \cong b_2`, then `(a_1 \vee b_1) \cong (a_2 \vee b_2)` and
         `(a_1 \wedge b_1) \cong (a_2 \wedge b_2)`.
 
         By the congruence generated by set of sets `\{S_1, \ldots, S_n\}` we
--- src/sage/combinat/posets/linear_extensions.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/posets/linear_extensions.py	2018-10-16 14:11:02.114640232 -0600
@@ -214,7 +214,7 @@ class LinearExtensionOfPoset(ClonableArr
         return P.relabel(relabelling).with_linear_extension(new)
 
     def is_greedy(self):
-        """
+        r"""
         Return ``True`` if the linear extension is greedy.
 
         A linear extension `[e_1, e_2, \ldots, e_n]` is *greedy* if for
@@ -360,7 +360,7 @@ class LinearExtensionOfPoset(ClonableArr
         return self
 
     def jump_count(self):
-        """
+        r"""
         Return the number of jumps in the linear extension.
 
         A *jump* in a linear extension `[e_1, e_2, \ldots, e_n]`
--- src/sage/combinat/posets/poset_examples.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/posets/poset_examples.py	2018-10-17 13:57:20.184033421 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 A catalog of posets and lattices.
 
 Some common posets can be accessed through the ``posets.<tab>`` object::
@@ -349,7 +349,7 @@ class Posets(object):
 
     @staticmethod
     def Crown(n, facade=None):
-        """
+        r"""
         Return the crown poset of `2n` elements.
 
         In this poset every element `i` for `0 \leq i \leq n-1`
@@ -565,7 +565,7 @@ class Posets(object):
 
     @staticmethod
     def PowerPoset(n):
-        """
+        r"""
         Return the power poset on `n` element posets.
 
         Elements of the power poset are all posets on
@@ -1509,7 +1509,7 @@ class Posets(object):
 
 
 def _random_lattice(n, p):
-    """
+    r"""
     Return a random lattice.
 
     INPUT:
@@ -1593,7 +1593,7 @@ def _random_lattice(n, p):
 
 
 def _random_dismantlable_lattice(n):
-    """
+    r"""
     Return a random dismantlable lattice on `n` elements.
 
     INPUT:
@@ -1636,7 +1636,7 @@ def _random_dismantlable_lattice(n):
 
 
 def _random_planar_lattice(n):
-    """
+    r"""
     Return a random planar lattice on `n` elements.
 
     INPUT:
--- src/sage/combinat/rigged_configurations/bij_type_D.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/rigged_configurations/bij_type_D.py	2018-10-16 14:12:31.090537073 -0600
@@ -378,7 +378,7 @@ class KRTToRCBijectionTypeD(KRTToRCBijec
                 self.ret_rig_con[i].vacancy_numbers[j] *= 2
 
     def halving_map(self):
-        """
+        r"""
         Perform the halving map of the rigged configuration at the current
         state of the bijection.
 
@@ -677,7 +677,7 @@ class RCToKRTBijectionTypeD(RCToKRTBijec
         return(b)
 
     def doubling_map(self):
-        """
+        r"""
         Perform the doubling map of the rigged configuration at the current
         state of the bijection.
 
@@ -714,7 +714,7 @@ class RCToKRTBijectionTypeD(RCToKRTBijec
                 partition.vacancy_numbers[j] *= 2
 
     def halving_map(self):
-        """
+        r"""
         Perform the halving map of the rigged configuration at the current
         state of the bijection.
 
@@ -742,7 +742,7 @@ class RCToKRTBijectionTypeD(RCToKRTBijec
                 partition.vacancy_numbers[j] //= 2
 
     def _correct_vacancy_nums(self):
-        """
+        r"""
         Correct the vacancy numbers with special considerations for spinor
         columns.
 
--- src/sage/combinat/rigged_configurations/kleber_tree.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/rigged_configurations/kleber_tree.py	2018-10-17 13:58:27.663164309 -0600
@@ -462,9 +462,9 @@ class KleberTreeNode(Element):
             ret_str = repr(self.multiplicity()) + ret_str
         for pair in self.weight:
             if pair[1] > 1:
-                ret_str += repr(pair[1]) + "\omega_{" + repr(pair[0]) + "}+"
+                ret_str += repr(pair[1]) + "\\omega_{" + repr(pair[0]) + "}+"
             elif pair[1] == 1:
-                ret_str += "\omega_{" + repr(pair[0]) + "}+"
+                ret_str += "\\omega_{" + repr(pair[0]) + "}+"
 
         if ret_str[-1] == '{':
             ret_str += "0}"
@@ -1066,7 +1066,7 @@ class KleberTree(UniqueRepresentation, P
     Element = KleberTreeNode
 
 class VirtualKleberTree(KleberTree):
-    """
+    r"""
     A virtual Kleber tree.
 
     We can use a modified version of the Kleber algorithm called the virtual
--- src/sage/combinat/rigged_configurations/rc_infinity.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/rigged_configurations/rc_infinity.py	2018-10-16 14:09:37.707686742 -0600
@@ -288,7 +288,7 @@ class InfinityCrystalOfRiggedConfigurati
         return R.weight_lattice()
 
     class Element(RiggedConfigurationElement):
-        """
+        r"""
         A rigged configuration in `\mathcal{B}(\infty)` in simply-laced types.
 
         TESTS::
@@ -492,7 +492,7 @@ class InfinityCrystalOfNonSimplyLacedRC(
                                   rigging_list=riggings)
 
     class Element(RCNonSimplyLacedElement):
-        """
+        r"""
         A rigged configuration in `\mathcal{B}(\infty)` in
         non-simply-laced types.
 
--- src/sage/combinat/rigged_configurations/rigged_configuration_element.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/rigged_configurations/rigged_configuration_element.py	2018-10-17 13:59:30.639353197 -0600
@@ -410,7 +410,7 @@ class RiggedConfigurationElement(Clonabl
         ret_string = self[0]._latex_()
 
         for partition in self[1:]:
-            ret_string += "\n\quad\n" + partition._latex_()
+            ret_string += "\n\\quad\n" + partition._latex_()
 
         return ret_string
 
@@ -923,7 +923,7 @@ class RCNonSimplyLacedElement(RiggedConf
         return self.parent().to_virtual(self)
 
     def e(self, a):
-        """
+        r"""
         Return the action of `e_a` on ``self``.
 
         This works by lifting into the virtual configuration, then applying
@@ -959,7 +959,7 @@ class RCNonSimplyLacedElement(RiggedConf
         return self.parent().from_virtual(virtual_rc)
 
     def f(self, a):
-        """
+        r"""
         Return the action of `f_a` on ``self``.
 
         This works by lifting into the virtual configuration, then applying
--- src/sage/combinat/rigged_configurations/rigged_configurations.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/rigged_configurations/rigged_configurations.py	2018-10-17 14:00:06.733888304 -0600
@@ -41,7 +41,7 @@ from sage.combinat.rigged_configurations
 
 # Used in the KR crystals catalog so that there is a common interface
 def KirillovReshetikhinCrystal(cartan_type, r, s):
-    """
+    r"""
     Return the KR crystal `B^{r,s}` using
     :class:`rigged configurations <RiggedConfigurations>`.
 
--- src/sage/combinat/root_system/ambient_space.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/ambient_space.py	2018-10-17 14:00:35.461518303 -0600
@@ -143,7 +143,7 @@ class AmbientSpace(CombinatorialFreeModu
 
     @classmethod
     def smallest_base_ring(cls, cartan_type=None):
-        """
+        r"""
         Return the smallest ground ring over which the ambient space can be realized.
 
         This class method will get called with the Cartan type as
@@ -263,7 +263,7 @@ class AmbientSpace(CombinatorialFreeModu
 
     @cached_method
     def fundamental_weight(self, i):
-        """
+        r"""
         Returns the fundamental weight `\Lambda_i` in ``self``
 
         In several of the ambient spaces, it is more convenient to
--- src/sage/combinat/root_system/cartan_type.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/cartan_type.py	2018-10-17 14:01:03.710154470 -0600
@@ -1506,7 +1506,7 @@ class CartanType_abstract(object):
         return CartanTypeFolded(self, folding_of, sigma)
 
     def _default_folded_cartan_type(self):
-        """
+        r"""
         Return the default folded Cartan type.
 
         In general, this just returns ``self`` in ``self`` with `\sigma` as
@@ -2540,7 +2540,7 @@ class CartanType_standard_finite(CartanT
     # mathematical methods
 
     def index_set(self):
-        """
+        r"""
         Implements :meth:`CartanType_abstract.index_set`.
 
         The index set for all standard finite Cartan types is of the form
--- src/sage/combinat/root_system/hecke_algebra_representation.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/hecke_algebra_representation.py	2018-10-16 14:17:11.462053939 -0600
@@ -801,7 +801,7 @@ class CherednikOperatorsEigenvectors(Uni
         classical operators `T_1, \ldots, T_n` from `T` and `T_Y` coincide.
     """
     def __init__(self, T, T_Y = None, normalized = True):
-        """
+        r"""
         INPUT:
 
         - ``T`` -- a family `(T_i)_{i\in I}` implementing the action of
@@ -947,7 +947,7 @@ class CherednikOperatorsEigenvectors(Uni
 
     @abstract_method
     def affine_retract(self, mu):
-        """
+        r"""
         Retract `\mu` from a space admitting an action of the affine Weyl group.
 
         EXAMPLES::
--- src/sage/combinat/root_system/integrable_representations.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/integrable_representations.py	2018-10-16 14:18:12.038298483 -0600
@@ -264,7 +264,7 @@ class IntegrableRepresentation(UniqueRep
 
     @cached_method
     def level(self):
-        """
+        r"""
         Return the level of ``self``.
 
         The level of a highest weight representation `V_{\Lambda}` is
@@ -325,7 +325,7 @@ class IntegrableRepresentation(UniqueRep
         return "Integrable representation of %s with highest weight %s"%(self._cartan_type, self._Lam)
 
     def _latex_(self):
-        """
+        r"""
         Return a latex representation of ``self``.
 
         EXAMPLES::
@@ -892,7 +892,7 @@ class IntegrableRepresentation(UniqueRep
         return tuple(ret)
 
     def string(self, max_weight, depth=12):
-        """
+        r"""
         Return the list of multiplicities `m(\Lambda - k \delta)` in
         ``self``, where `\Lambda` is ``max_weight`` and `k` runs from `0`
         to ``depth``.
--- src/sage/combinat/root_system/reflection_group_complex.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/reflection_group_complex.py	2018-10-17 14:01:55.813483394 -0600
@@ -1423,8 +1423,8 @@ class ComplexReflectionGroup(UniqueRepre
         x = P.gens()
         for i in range(len(I)):
             I[i] = I[i].replace('^','**')
-            I[i] = re.compile('E(\d\d*)').sub(r'E(\1)', I[i])
-            I[i] = re.compile('(\d)E\(').sub(r'\1*E(', I[i])
+            I[i] = re.compile(r'E(\d\d*)').sub(r'E(\1)', I[i])
+            I[i] = re.compile(r'(\d)E\(').sub(r'\1*E(', I[i])
             for j in range(len(x)):
                 I[i] = I[i].replace('x%s'%j,'*x[%s]'%j)
             I[i] = I[i].replace("+*","+").replace("-*","-").replace("ER(5)","*(E(5)-E(5)**2-E(5)**3+E(5)**4)").lstrip("*")
--- src/sage/combinat/root_system/root_lattice_realization_algebras.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/root_lattice_realization_algebras.py	2018-10-16 14:19:44.357147158 -0600
@@ -872,7 +872,7 @@ class Algebras(AlgebrasCategory):
             return self.basis().keys().classical().algebra(self.base_ring())
 
         def q_project_on_basis(self, l, q):
-            """
+            r"""
             Return the monomial `c * cl(l)`  in the group algebra of the classical lattice.
 
             INPUT:
@@ -900,7 +900,7 @@ class Algebras(AlgebrasCategory):
             return KL0.term(L0(l), q**l["delta"])
 
         def q_project(self, x, q):
-            """
+            r"""
             Implement the `q`-projection morphism from ``self`` to the group algebra of the classical space.
 
             INPUT:
--- src/sage/combinat/root_system/root_lattice_realizations.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/root_lattice_realizations.py	2018-10-17 14:02:38.772930091 -0600
@@ -1215,7 +1215,7 @@ class RootLatticeRealizations(Category_o
             return self.root_system.coroot_lattice()
 
         def coroot_space(self, base_ring = QQ):
-            """
+            r"""
             Returns the coroot space over ``base_ring``
 
             INPUT:
@@ -1497,7 +1497,7 @@ class RootLatticeRealizations(Category_o
 
         @cached_method
         def simple_reflections(self):
-            """
+            r"""
             Returns the family `(s_i)_{i\in I}` of the simple reflections
             of this root system.
 
--- src/sage/combinat/root_system/type_A_affine.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/type_A_affine.py	2018-10-16 14:18:44.476893935 -0600
@@ -205,7 +205,7 @@ class CartanType(CartanType_standard_unt
         return self
 
     def _default_folded_cartan_type(self):
-        """
+        r"""
         Return the default folded Cartan type.
 
         In general, this just returns ``self`` in ``self`` with `\sigma` as
--- src/sage/combinat/root_system/type_A_infinity.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/type_A_infinity.py	2018-10-16 14:20:50.068327656 -0600
@@ -77,7 +77,7 @@ class CartanType(CartanType_standard, Ca
         return ret % (self.letter, 'ZZ' if self.n == ZZ else 'NN')
 
     def _latex_(self):
-        """
+        r"""
         Return a latex representation of ``self``.
 
         EXAMPLES::
@@ -225,7 +225,7 @@ class CartanType(CartanType_standard, Ca
         return self.letter
 
     def index_set(self):
-        """
+        r"""
         Return the index set for the Cartan type ``self``.
 
         The index set for all standard finite Cartan types is of the form
--- src/sage/combinat/root_system/type_dual.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/type_dual.py	2018-10-16 14:21:28.323850557 -0600
@@ -654,7 +654,7 @@ class CartanType_affine(CartanType, cart
                 return "E_6^{(2)}"
         result = self._type._latex_()
         import re
-        if re.match(".*\^{\(\d\)}$", result):
+        if re.match(r".*\^{\(\d\)}$", result):
             return "%s%s}"%(result[:-1], self.options('dual_latex'))
         else:
             return "{%s}^%s"%(result, self.options('dual_latex'))
--- src/sage/combinat/root_system/type_folded.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/type_folded.py	2018-10-16 14:21:45.531635948 -0600
@@ -252,7 +252,7 @@ class CartanTypeFolded(UniqueRepresentat
 
     @cached_method
     def folding_orbit(self):
-        """
+        r"""
         Return the orbits under the automorphism `\sigma` as a
         dictionary (of tuples).
 
--- src/sage/combinat/root_system/type_reducible.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/type_reducible.py	2018-10-16 14:22:13.162291360 -0600
@@ -234,7 +234,7 @@ class CartanType(SageObject, CartanType_
 
     @cached_method
     def index_set(self):
-        """
+        r"""
         Implements :meth:`CartanType_abstract.index_set`.
 
         For the moment, the index set is always of the form `\{1, \ldots, n\}`.
--- src/sage/combinat/root_system/type_super_A.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/type_super_A.py	2018-10-16 14:20:09.819829604 -0600
@@ -236,7 +236,7 @@ class AmbientSpace(ambient_space.Ambient
                 for j in range(1, ct.n + 2)]
 
     def fundamental_weight(self, i):
-        """
+        r"""
         Return the fundamental weight `\Lambda_i` of ``self``.
 
         EXAMPLES::
--- src/sage/combinat/root_system/weight_lattice_realizations.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/weight_lattice_realizations.py	2018-10-17 14:03:27.043308391 -0600
@@ -129,7 +129,7 @@ class WeightLatticeRealizations(Category
 
         @abstract_method
         def fundamental_weight(self, i):
-            """
+            r"""
             Returns the `i^{th}` fundamental weight
 
             INPUT:
@@ -188,7 +188,7 @@ class WeightLatticeRealizations(Category
           return False
 
         def __init_extra__(self):
-            """
+            r"""
             Registers the embedding of the weight lattice into ``self``
 
             Also registers the embedding of the weight space over the same
@@ -511,7 +511,7 @@ class WeightLatticeRealizations(Category
             return f(self.rho()).reduced_word()
 
         def dynkin_diagram_automorphism_of_alcove_morphism(self, f):
-            """
+            r"""
             Returns the Dynkin diagram automorphism induced by an alcove morphism
 
             INPUT:
@@ -582,7 +582,7 @@ class WeightLatticeRealizations(Category
             return permutation
 
         def reduced_word_of_translation(self, t):
-            """
+            r"""
             Given an element of the root lattice, this returns a reduced
             word `i_1,...,i_k` such that the Weyl group element `s_{i_1}
             \circ \dots \circ s_{i_k}` implements the "translation"
--- src/sage/combinat/root_system/weight_space.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/weight_space.py	2018-10-17 14:03:57.826911909 -0600
@@ -238,7 +238,7 @@ class WeightSpace(CombinatorialFreeModul
 
     @cached_method
     def fundamental_weight(self, i):
-        """
+        r"""
         Returns the `i`-th fundamental weight
 
         INPUT:
@@ -304,7 +304,7 @@ class WeightSpace(CombinatorialFreeModul
 
     @cached_method
     def simple_root(self, j):
-        """
+        r"""
         Returns the `j^{th}` simple root
 
         EXAMPLES::
--- src/sage/combinat/root_system/weyl_characters.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/root_system/weyl_characters.py	2018-10-17 14:04:53.411195998 -0600
@@ -22,7 +22,7 @@ from sage.rings.all import ZZ
 
 
 class WeylCharacterRing(CombinatorialFreeModule):
-    """
+    r"""
     A class for rings of Weyl characters.
 
     Let `K` be a compact Lie group, which we assume is semisimple and
@@ -1343,7 +1343,7 @@ class WeylCharacterRing(CombinatorialFre
             return self.parent().char_from_weights(d)
 
         def frobenius_schur_indicator(self):
-            """
+            r"""
             Return:
 
             - `1` if the representation is real (orthogonal)
@@ -1459,7 +1459,7 @@ class WeylCharacterRing(CombinatorialFre
             return self.coefficient(other.support()[0])
 
 def irreducible_character_freudenthal(hwv, debug=False):
-    """
+    r"""
     Return the dictionary of multiplicities for the irreducible
     character with highest weight `\lambda`.
 
@@ -1907,7 +1907,7 @@ class WeightRing(CombinatorialFreeModule
             return self.parent()._from_dict(d2)
 
         def shift(self, mu):
-            """
+            r"""
             Add `\mu` to any weight. Extended by linearity to the weight ring.
 
             INPUT:
--- src/sage/combinat/sf/character.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/sf/character.py	2018-10-16 14:23:10.610574904 -0600
@@ -8,7 +8,7 @@ of `S_n` when the group is realized as t
 
 REFERENCES:
 
-.. [OZ2015] \R. Orellana, M. Zabrocki, *Symmetric group characters
+.. [OZ2015] \\R. Orellana, M. Zabrocki, *Symmetric group characters
    as symmetric functions*, :arxiv:`1510.00438`.
 """
 
--- src/sage/combinat/sf/homogeneous.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/sf/homogeneous.py	2018-10-17 14:05:17.577884739 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 Homogeneous symmetric functions
 
 By this we mean the basis formed of the complete homogeneous
--- src/sage/combinat/sf/multiplicative.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/sf/multiplicative.py	2018-10-17 14:05:55.929390781 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 Multiplicative symmetric functions
 
 A realization `h` of the ring of symmetric functions is multiplicative if for
@@ -24,7 +24,7 @@ from . import classical
 import sage.combinat.partition
 
 class SymmetricFunctionAlgebra_multiplicative(classical.SymmetricFunctionAlgebra_classical):
-    """
+    r"""
     The class of multiplicative bases of the ring of symmetric functions.
 
     A realization `q` of the ring of symmetric functions is multiplicative if
--- src/sage/combinat/sf/new_kschur.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/sf/new_kschur.py	2018-10-16 14:23:49.225093338 -0600
@@ -859,7 +859,7 @@ class KBoundedSubspaceBases(Category_rea
 
 
 class kSchur(CombinatorialFreeModule):
-    """
+    r"""
     Space of `k`-Schur functions.
 
     EXAMPLES::
--- src/sage/combinat/sf/orthotriang.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/sf/orthotriang.py	2018-10-17 14:06:23.633033965 -0600
@@ -187,7 +187,7 @@ class SymmetricFunctionAlgebra_orthotria
                               self._base_to_self_cache, to_other_function = self._to_base)
 
     def _to_base(self, part):
-        """
+        r"""
         Returns a function which takes in a partition `\mu` and returns the
         coefficient of a partition in the expansion of ``self`` `(part)` in base.
 
--- src/sage/combinat/sf/schur.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/sf/schur.py	2018-10-17 14:06:41.304806359 -0600
@@ -271,7 +271,7 @@ class SymmetricFunctionAlgebra_schur(cla
         omega_involution = omega
 
         def scalar(self, x, zee=None):
-            """
+            r"""
             Return the standard scalar product between ``self`` and `x`.
 
             Note that the Schur functions are self-dual with respect to this
--- src/sage/combinat/sf/sf.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/sf/sf.py	2018-10-17 14:06:58.985578637 -0600
@@ -1370,7 +1370,7 @@ class SymmetricFunctions(UniqueRepresent
         return self.m().from_polynomial(f)
 
     def register_isomorphism(self, morphism, only_conversion=False):
-        """
+        r"""
         Register an isomorphism between two bases of ``self``, as a canonical coercion
         (unless the optional keyword ``only_conversion`` is set to ``True``,
         in which case the isomorphism is registered as conversion only).
--- src/sage/combinat/species/combinatorial_logarithm.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/species/combinatorial_logarithm.py	2018-10-16 14:24:12.017809085 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 Combinatorial Logarithm
 
 This file provides the cycle index series for the virtual species `\Omega`,
--- src/sage/combinat/species/generating_series.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/species/generating_series.py	2018-10-17 14:08:27.232442046 -0600
@@ -586,7 +586,7 @@ class CycleIndexSeries(LazyPowerSeries):
             yield self.coefficient(i).coefficient([1]*i)
 
     def __invert__(self):
-        """
+        r"""
         Return the multiplicative inverse of ``self``.
 
         This algorithm is derived from [BLL]_.
@@ -740,7 +740,7 @@ class CycleIndexSeries(LazyPowerSeries):
             [0, 1, 3, 8, 42, 144, 1440, 5760]
 
         It is shown in [MM]_ that the exponential generating function for regular octopuses satisfies
-        `(C \\boxdot L_{+}) (x) = \\sum_{n \geq 1} \\sigma (n) (n - 1)! \\frac{x^{n}}{n!}` (where `\\sigma (n)` is
+        `(C \\boxdot L_{+}) (x) = \\sum_{n \\geq 1} \\sigma (n) (n - 1)! \\frac{x^{n}}{n!}` (where `\\sigma (n)` is
         the sum of the divisors of `n`). ::
 
             sage: RegOctDirectSeq = [0] + [sum(divisors(i))*factorial(i-1) for i in range(1,8)]
@@ -753,7 +753,7 @@ class CycleIndexSeries(LazyPowerSeries):
 
         REFERENCES:
 
-        .. [MM] \M. Maia and M. Mendez. "On the arithmetic product of combinatorial species".
+        .. [MM] \\M. Maia and M. Mendez. "On the arithmetic product of combinatorial species".
            Discrete Mathematics, vol. 308, issue 23, 2008, pp. 5407-5427.
            :arXiv:`math/0503436v2`.
 
@@ -1291,7 +1291,7 @@ def ExponentialCycleIndexSeries(R = Rati
 
 @cached_function
 def _cl_term(n, R = RationalField()):
-    """
+    r"""
     Compute the order-n term of the cycle index series of the virtual species `\Omega`,
     the compositional inverse of the species `E^{+}` of nonempty sets.
 
@@ -1315,7 +1315,7 @@ def _cl_term(n, R = RationalField()):
     return res
 
 def _cl_gen (R = RationalField()):
-    """
+    r"""
     Produce a generator which yields the terms of the cycle index series of the virtual species
     `\Omega`, the compositional inverse of the species `E^{+}` of nonempty sets.
 
@@ -1330,7 +1330,7 @@ def _cl_gen (R = RationalField()):
 
 @cached_function
 def LogarithmCycleIndexSeries(R = RationalField()):
-    """
+    r"""
     Return the cycle index series of the virtual species `\Omega`, the compositional inverse
     of the species `E^{+}` of nonempty sets.
 
--- src/sage/combinat/species/library.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/species/library.py	2018-10-17 14:08:48.023174267 -0600
@@ -73,7 +73,7 @@ def SimpleGraphSpecies():
 
 @cached_function
 def BinaryTreeSpecies():
-    """
+    r"""
     Returns the species of binary trees on n leaves. The species of
     binary trees B is defined by B = X + B\*B where X is the singleton
     species.
--- src/sage/combinat/species/series.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/species/series.py	2018-10-17 14:09:10.383886267 -0600
@@ -1128,7 +1128,7 @@ class LazyPowerSeries(AlgebraElement):
     times = _mul_
 
     def _times_gen(self, y, ao):
-        """
+        r"""
         Returns an iterator for the coefficients of self \* y.
 
         EXAMPLES::
--- src/sage/combinat/species/species.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/species/species.py	2018-10-17 14:09:28.222656513 -0600
@@ -178,7 +178,7 @@ class GenericCombinatorialSpecies(SageOb
         return not (self == other)
     
     def __getstate__(self):
-        """
+        r"""
         This is used during the pickling process and returns a dictionary
         of the data needed to create this object during the unpickling
         process. It returns an (\*args, \*\*kwds) tuple which is to be
--- src/sage/combinat/species/structure.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/species/structure.py	2018-10-17 14:09:47.503408187 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 Species structures
 
 We will illustrate the use of the structure classes using the
--- src/sage/combinat/words/finite_word.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/words/finite_word.py	2018-10-17 14:10:12.977080094 -0600
@@ -632,7 +632,7 @@ class FiniteWord_class(Word_class):
         return True
 
     def schuetzenberger_involution(self, n = None):
-        """
+        r"""
         Return the Schützenberger involution of the word ``self``, which is obtained
         by reverting the word and then complementing all letters within the
         underlying ordered alphabet. If ``n`` is specified, the underlying
--- src/sage/combinat/words/morphism.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/words/morphism.py	2018-10-17 14:10:57.783503003 -0600
@@ -888,7 +888,7 @@ class WordMorphism(SageObject):
             for a in A:
                 lines.append(r"%s \mapsto %s"% (a, self.image(a)))
             s += '\\\\\n'.join(lines)
-            s += '\n' + "\end{array}"
+            s += '\n' + r"\end{array}"
             return LatexExpr(s)
         else:
             raise ValueError('unknown latex_layout(=%s)' % latex_layout)
--- src/sage/combinat/words/word_generators.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/words/word_generators.py	2018-10-17 14:11:14.926282211 -0600
@@ -1359,7 +1359,7 @@ class WordGenerator(object):
         return W(w)
 
     def RandomWord(self, n, m=2, alphabet=None):
-        """
+        r"""
         Returns a random word of length `n` over the given `m`-letter
         alphabet.
 
--- src/sage/crypto/mq/sr.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/crypto/mq/sr.py	2018-10-16 14:31:58.645989660 -0600
@@ -1080,7 +1080,7 @@ class SR_generic(MPolynomialSystemGenera
         return random_matrix(self.base_ring(), self._r, self._c, *args, **kwds)
 
     def random_vector(self, *args, **kwds):
-        """
+        r"""
         Return a random vector as it might appear in the algebraic
         expression of self.
 
@@ -1534,7 +1534,7 @@ class SR_generic(MPolynomialSystemGenera
 
 
     def varformatstr(self, name, n=None, rc=None, e=None):
-        """
+        r"""
         Return a format string which is understood by print et al.
 
         If a numerical value is omitted, the default value of ``self``
@@ -1913,7 +1913,7 @@ class SR_generic(MPolynomialSystemGenera
             return tuple(lin + sbox)
 
     def key_schedule_polynomials(self, i):
-        """
+        r"""
         Return polynomials for the `i`-th round of the key
         schedule.
 
@@ -2251,7 +2251,7 @@ class SR_gf2n(SR_generic):
             raise TypeError
 
     def antiphi(self, l):
-        """
+        r"""
         The operation `\phi^{-1}` from [MR2002]_ or the inverse of ``self.phi``.
 
         INPUT:
@@ -2472,7 +2472,7 @@ class SR_gf2n(SR_generic):
         return [xi[j, 0]*wi[j, 0] + 1 for j in range(length)]
 
     def field_polynomials(self, name, i, l=None):
-        """
+        r"""
         Return list of conjugacy polynomials for a given round ``i``
         and name ``name``.
 
@@ -2657,7 +2657,7 @@ class SR_gf2(SR_generic):
         else: raise TypeError
 
     def antiphi(self, l):
-        """
+        r"""
         The operation `\phi^{-1}` from [MR2002]_ or the inverse of ``self.phi``.
 
         INPUT:
@@ -3197,7 +3197,7 @@ class SR_gf2(SR_generic):
         return l
 
     def field_polynomials(self, name, i, l=None):
-        """
+        r"""
         Return list of field polynomials for a given round ``i`` and
         name ``name``.
 
--- src/sage/doctest/parsing.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/doctest/parsing.py	2018-10-16 14:33:57.099513779 -0600
@@ -38,7 +38,7 @@ from functools import reduce
 
 from .external import available_software
 
-float_regex = re.compile('\s*([+-]?\s*((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?)')
+float_regex = re.compile(r'\s*([+-]?\s*((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?)')
 optional_regex = re.compile(r'(py2|py3|long time|not implemented|not tested|known bug)|([^ a-z]\s*optional\s*[:-]*((\s|\w)*))')
 find_sage_prompt = re.compile(r"^(\s*)sage: ", re.M)
 find_sage_continuation = re.compile(r"^(\s*)\.\.\.\.:", re.M)
--- src/sage/doctest/sources.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/doctest/sources.py	2018-10-16 14:33:31.291835104 -0600
@@ -36,7 +36,7 @@ from sage.structure.dynamic_class import
 from sage.env import SAGE_SRC, SAGE_LOCAL
 
 # Python file parsing
-triple_quotes = re.compile("\s*[rRuU]*((''')|(\"\"\"))")
+triple_quotes = re.compile("\\s*[rRuU]*((''')|(\"\"\"))")
 name_regex = re.compile(r".*\s(\w+)([(].*)?:")
 
 # LaTeX file parsing
@@ -50,7 +50,7 @@ skip = re.compile(r".*%skip.*")
 link_all = re.compile(r"^\s*\.\.\s+linkall\s*$")
 double_colon = re.compile(r"^(\s*).*::\s*$")
 
-whitespace = re.compile("\s*")
+whitespace = re.compile("\\s*")
 bitness_marker = re.compile('#.*(32|64)-bit')
 bitness_value = '64' if sys.maxsize > (1 << 32) else '32'
 
--- src/sage/functions/error.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/error.py	2018-10-17 14:17:56.353108811 -0600
@@ -293,7 +293,7 @@ class Function_erf(BuiltinFunction):
 erf = Function_erf()
 
 class Function_erfi(BuiltinFunction):
-    """
+    r"""
     The imaginary error function.
 
     The imaginary error function is defined by
@@ -465,7 +465,7 @@ erfc = Function_erfc()
 
 
 class Function_erfinv(BuiltinFunction):
-    """
+    r"""
     The inverse error function.
 
     The inverse error function is defined by:
--- src/sage/functions/exp_integral.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/exp_integral.py	2018-10-17 14:18:40.105544699 -0600
@@ -643,7 +643,7 @@ class Function_log_integral_offset(Built
         return mpmath_utils_call(mpmath.li, z, offset=True, parent=parent)
 
     def _derivative_(self, z, diff_param=None):
-        """
+        r"""
         The derivative of `\operatorname{Li}(z) is `1/log(z)`.
 
         EXAMPLES::
@@ -800,7 +800,7 @@ class Function_sin_integral(BuiltinFunct
             return z
 
     def _evalf_(self, z, parent=None, algorithm=None):
-        """
+        r"""
         EXAMPLES:
 
         The limit `\operatorname{Si}(z)` as `z \to \infty`  is `\pi/2`::
@@ -1248,7 +1248,7 @@ class Function_cosh_integral(BuiltinFunc
         return mpmath_utils_call(mpmath.chi, z, parent=parent)
 
     def _derivative_(self, z, diff_param=None):
-        """
+        r"""
         The derivative of `\operatorname{Chi}(z)` is `\cosh(z)/z`.
 
         EXAMPLES::
--- src/sage/functions/generalized.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/generalized.py	2018-10-17 14:19:00.728278808 -0600
@@ -629,7 +629,7 @@ class FunctionKroneckerDelta(BuiltinFunc
         return 0
 
     def _print_latex_(self, m, n, **kwds):
-        """
+        r"""
         Return latex expression
 
         EXAMPLES::
--- src/sage/functions/hypergeometric.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/hypergeometric.py	2018-10-17 14:19:28.326922969 -0600
@@ -956,7 +956,7 @@ class Hypergeometric_M(BuiltinFunction):
         1/2*sqrt(pi)*erf(1)*e
     """
     def __init__(self):
-        """
+        r"""
         TESTS::
         
             sage: maxima(hypergeometric_M(1,1,x))
@@ -1067,7 +1067,7 @@ class Hypergeometric_U(BuiltinFunction):
 
     """
     def __init__(self):
-        """
+        r"""
         TESTS::
         
             sage: maxima(hypergeometric_U(1,1,x))
--- src/sage/functions/log.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/log.py	2018-10-17 14:19:54.168589789 -0600
@@ -871,7 +871,7 @@ class Function_lambert_w(BuiltinFunction
             return mpmath_utils.call(mpmath.lambertw, z, n, parent=R)
 
     def _derivative_(self, n, z, diff_param=None):
-        """
+        r"""
         The derivative of `W_n(x)` is `W_n(x)/(x \cdot W_n(x) + x)`.
 
         EXAMPLES::
@@ -945,7 +945,7 @@ class Function_lambert_w(BuiltinFunction
             return "lambert_w(%s, %s)" % (n, z)
 
     def _print_latex_(self, n, z):
-        """
+        r"""
         Custom _print_latex_ method to avoid printing the branch
         number if it is zero.
 
--- src/sage/functions/min_max.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/min_max.py	2018-10-17 14:20:37.478031389 -0600
@@ -193,7 +193,7 @@ class MaxSymbolic(MinMax_base):
             sage: max_symbolic(x, 5)._sympy_()
             Max(5, x)
         """
-        BuiltinFunction.__init__(self, 'max', nargs=0, latex_name="\max",
+        BuiltinFunction.__init__(self, 'max', nargs=0, latex_name=r"\max",
                                  conversions=dict(sympy='Max'))
 
     def _eval_(self, *args):
@@ -282,7 +282,7 @@ class MinSymbolic(MinMax_base):
             sage: min_symbolic(x, 5)._sympy_()
             Min(5, x)
         """
-        BuiltinFunction.__init__(self, 'min', nargs=0, latex_name="\min",
+        BuiltinFunction.__init__(self, 'min', nargs=0, latex_name=r"\min",
                                  conversions=dict(sympy='Min'))
 
     def _eval_(self, *args):
--- src/sage/functions/piecewise.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/piecewise.py	2018-10-16 14:34:26.243150924 -0600
@@ -889,7 +889,7 @@ class PiecewiseFunction(BuiltinFunction)
             return crit_pts
 
         def convolution(self, parameters, variable, other):
-            """
+            r"""
             Return the convolution function,
             `f*g(t)=\int_{-\infty}^\infty f(u)g(t-u)du`, for compactly
             supported `f,g`.
--- src/sage/functions/special.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/special.py	2018-10-17 14:21:31.654332885 -0600
@@ -474,7 +474,7 @@ class EllipticE(BuiltinFunction):
             return (elliptic_e(z, m) - elliptic_f(z, m)) / (Integer(2) * m)
 
     def _print_latex_(self, z, m):
-        """
+        r"""
         EXAMPLES::
 
             sage: latex(elliptic_e(pi, x))
@@ -485,7 +485,7 @@ class EllipticE(BuiltinFunction):
 elliptic_e = EllipticE()
 
 class EllipticEC(BuiltinFunction):
-    """
+    r"""
     Return the complete elliptic integral of the second kind:
 
     .. MATH::
@@ -788,7 +788,7 @@ class EllipticF(BuiltinFunction):
                       sqrt(Integer(1) - m * sin(z) ** Integer(2)))))
 
     def _print_latex_(self, z, m):
-        """
+        r"""
         EXAMPLES::
 
             sage: latex(elliptic_f(x,pi))
@@ -1003,7 +1003,7 @@ class EllipticPi(BuiltinFunction):
                      sqrt(Integer(1) - m * sin(z) ** Integer(2)))))
 
     def _print_latex_(self, n, z, m):
-        """
+        r"""
         EXAMPLES::
 
             sage: latex(elliptic_pi(x,pi,0))
--- src/sage/functions/trig.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/functions/trig.py	2018-10-17 14:22:17.565740945 -0600
@@ -7,7 +7,7 @@ import math
 
 class Function_sin(GinacFunction):
     def __init__(self):
-        """
+        r"""
         The sine function.
 
         EXAMPLES::
@@ -124,7 +124,7 @@ sin = Function_sin()
 
 class Function_cos(GinacFunction):
     def __init__(self):
-        """
+        r"""
         The cosine function.
 
         EXAMPLES::
@@ -186,7 +186,7 @@ cos = Function_cos()
 
 class Function_tan(GinacFunction):
     def __init__(self):
-        """
+        r"""
         The tangent function.
 
         EXAMPLES::
--- src/sage/homology/chains.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/chains.py	2018-10-17 14:12:50.253054434 -0600
@@ -476,7 +476,7 @@ class Cochains(CellComplexReference, Com
             })
 
         def coboundary(self):
-            """
+            r"""
             Return the coboundary of this cochain
 
             OUTPUT:
@@ -556,7 +556,7 @@ class Cochains(CellComplexReference, Com
             return self.to_complex().is_boundary()
 
         def eval(self, other):
-            """
+            r"""
             Evaluate this cochain on the chain ``other``.
 
             INPUT:
@@ -607,7 +607,7 @@ class Cochains(CellComplexReference, Com
             return R(result)
 
         def cup_product(self, cochain):
-            """
+            r"""
             Return the cup product with another cochain
 
             INPUT:
--- src/sage/homology/delta_complex.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/delta_complex.py	2018-10-17 14:13:10.124798492 -0600
@@ -1720,7 +1720,7 @@ class DeltaComplexExamples():
         return DeltaComplex({Simplex(n): True})
 
     def SurfaceOfGenus(self, g, orientable=True):
-        """
+        r"""
         A surface of genus g as a `\Delta`-complex.
 
         :param g: the genus
--- src/sage/homology/hochschild_complex.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/hochschild_complex.py	2018-10-16 14:28:16.894755162 -0600
@@ -349,7 +349,7 @@ class HochschildComplex(UniqueRepresenta
         return cod.module_morphism(matrix=bdry.matrix().transpose(), codomain=dom)
 
     def homology(self, d):
-        """
+        r"""
         Return the ``d``-th homology group.
 
         EXAMPLES::
@@ -403,7 +403,7 @@ class HochschildComplex(UniqueRepresenta
         return ker.quotient_module(im_retract)
 
     def cohomology(self, d):
-        """
+        r"""
         Return the ``d``-th cohomology group.
 
         EXAMPLES::
--- src/sage/homology/homology_group.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/homology_group.py	2018-10-17 14:13:39.148424676 -0600
@@ -111,7 +111,7 @@ class HomologyGroup_class(AdditiveAbelia
             sage: H._latex_()
             'C_{4}^{5} \\times C_{7} \\times C_{7}'
             sage: latex(HomologyGroup(6, ZZ))
-            \ZZ^{6}
+            \\ZZ^{6}
         """
         eldv = self._original_invts
         if len(eldv) == 0:
--- src/sage/homology/homology_vector_space_with_basis.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/homology_vector_space_with_basis.py	2018-10-16 14:28:41.574447379 -0600
@@ -333,7 +333,7 @@ class HomologyVectorSpaceWithBasis(Combi
 
     @cached_method
     def _to_cycle_on_basis(self, i):
-        """
+        r"""
         Return the (co)cycle representative of the basis element
         indexed by ``i``.
 
--- src/sage/homology/simplicial_set_constructions.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/simplicial_set_constructions.py	2018-10-16 14:26:51.567819300 -0600
@@ -972,7 +972,7 @@ class ProductOfSimplicialSets(PullbackOf
         return ' x '.join([str(X) for X in self._factors])
 
     def _latex_(self):
-        """
+        r"""
         LaTeX representation
 
         EXAMPLES::
@@ -1805,7 +1805,7 @@ class QuotientOfSimplicialSet(PushoutOfS
         return 'Quotient: ({}/{})'.format(self.ambient(), self.subcomplex())
 
     def _latex_(self):
-        """
+        r"""
         LaTeX representation
 
         EXAMPLES::
@@ -1942,7 +1942,7 @@ class SmashProductOfSimplicialSets_finit
         return s
 
     def _latex_(self):
-        """
+        r"""
         LaTeX representation
 
         EXAMPLES::
@@ -2405,7 +2405,7 @@ class ConeOfSimplicialSet(SimplicialSet_
         return 'Cone of {}'.format(self._base)
 
     def _latex_(self):
-        """
+        r"""
         LaTeX representation
 
         EXAMPLES::
--- src/sage/homology/simplicial_set_examples.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/simplicial_set_examples.py	2018-10-16 14:27:12.503558208 -0600
@@ -335,7 +335,7 @@ def ClassifyingSpace(group):
 
 
 def RealProjectiveSpace(n):
-    """
+    r"""
     Return real `n`-dimensional projective space, as a simplicial set.
 
     This is constructed as the `n`-skeleton of the nerve of the group
--- src/sage/homology/simplicial_set_morphism.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/simplicial_set_morphism.py	2018-10-16 14:27:46.759130992 -0600
@@ -300,7 +300,7 @@ class SimplicialSetHomset(Homset):
                 pass
 
     def _latex_(self):
-        """
+        r"""
         LaTeX representation
 
         EXAMPLES::
--- src/sage/homology/simplicial_set.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/homology/simplicial_set.py	2018-10-16 14:25:47.346620222 -0600
@@ -962,7 +962,7 @@ class NonDegenerateSimplex(AbstractSimpl
 
 def AbstractSimplex(dim, degeneracies=(), underlying=None,
                     name=None, latex_name=None):
-    """
+    r"""
     An abstract simplex, a building block of a simplicial set.
 
     In a simplicial set, a simplex either is non-degenerate or is
--- src/sage/interfaces/axiom.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/axiom.py	2018-10-17 14:44:21.199671183 -0600
@@ -216,7 +216,7 @@ class PanAxiom(ExtraTabCompletion, Expec
         self._COMMANDS_CACHE = '%s/%s_commandlist_cache.sobj'%(DOT_SAGE, name)
         Expect.__init__(self,
                         name = name,
-                        prompt = '\([0-9]+\) -> ',
+                        prompt = r'\([0-9]+\) -> ',
                         command = command,
                         script_subdirectory = script_subdirectory,
                         server=server,
--- src/sage/interfaces/chomp.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/chomp.py	2018-10-16 14:30:11.933320492 -0600
@@ -47,7 +47,7 @@ def have_chomp(program='homsimpl'):
     return _have_chomp[program]
 
 class CHomP:
-    """
+    r"""
     Interface to the CHomP package.
 
     :param program: which CHomP program to use
@@ -295,7 +295,7 @@ class CHomP:
                 if hom_str.find("^") != -1:
                     rk_srch = re.search(r'\^([0-9]*)\s?', hom_str)
                     rk = int(rk_srch.group(1))
-                rk += len(re.findall("(Z$)|(Z\s)", hom_str))
+                rk += len(re.findall(r"(Z$)|(Z\s)", hom_str))
                 if mod_p:
                     rk = rk if rk != 0 else 1
                     if verbose:
@@ -664,7 +664,7 @@ def process_generators_cubical(gen_strin
         # drop the first coordinate and eliminate duplicates, at least
         # in positive dimensions, drop any line containing a
         # degenerate cube
-        g = re.sub('\([01],', '(', g)
+        g = re.sub(r'\([01],', '(', g)
         if dim > 0:
             lines = g.splitlines()
             newlines = []
--- src/sage/interfaces/ecm.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/ecm.py	2018-10-17 14:45:01.630149706 -0600
@@ -320,15 +320,15 @@ class ECM(SageObject):
         return self._recommended_B1_list[self._B1_table_value(factor_digits)]
 
     _parse_status_re = re.compile(
-        'Using B1=(\d+), B2=(\d+), polynomial ([^,]+), sigma=(\d+)')
+        r'Using B1=(\d+), B2=(\d+), polynomial ([^,]+), sigma=(\d+)')
 
     _found_input_re = re.compile('Found input number N')
 
     _found_factor_re = re.compile(
-        'Found (?P<primality>.*) factor of [\s]*(?P<digits>\d+) digits: (?P<factor>\d+)')
+        r'Found (?P<primality>.*) factor of [\s]*(?P<digits>\d+) digits: (?P<factor>\d+)')
 
     _found_cofactor_re = re.compile(
-        '(?P<primality>.*) cofactor (?P<cofactor>\d+) has [\s]*(?P<digits>\d+) digits')
+        r'(?P<primality>.*) cofactor (?P<cofactor>\d+) has [\s]*(?P<digits>\d+) digits')
 
     def _parse_output(self, n, out):
         """
--- src/sage/interfaces/fricas.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/fricas.py	2018-10-17 14:49:20.554800360 -0600
@@ -208,7 +208,7 @@ FRICAS_SINGLE_LINE_START = 3 # where the
 FRICAS_MULTI_LINE_START = 2  # and when it doesn't
 FRICAS_LINE_LENGTH = 80      # length of a line, should match the line length in sage
 # the following messages have, unfortunately, no markup.
-FRICAS_WHAT_OPERATIONS_STRING = "Operations whose names satisfy the above pattern\(s\):"
+FRICAS_WHAT_OPERATIONS_STRING = r"Operations whose names satisfy the above pattern\(s\):"
 FRICAS_ERROR_IN_LIBRARY_CODE = ">> Error detected within library code:"
 
 # only the last command should be necessary to make the interface
@@ -227,8 +227,8 @@ FRICAS_INIT_CODE = (
 "               (princ #\\Newline))))")
 
 FRICAS_LINENUMBER_OFF_CODE = ")lisp (setf |$IOindex| NIL)"
-FRICAS_FIRST_PROMPT = "\(1\) -> "
-FRICAS_LINENUMBER_OFF_PROMPT = "\(NIL\) -> "
+FRICAS_FIRST_PROMPT = r"\(1\) -> "
+FRICAS_LINENUMBER_OFF_PROMPT = r"\(NIL\) -> "
 
 class FriCAS(ExtraTabCompletion, Expect):
     """
@@ -344,7 +344,7 @@ class FriCAS(ExtraTabCompletion, Expect)
             True
         """
         output = self.eval(")what operations", reformat=False)
-        m = re.search(FRICAS_WHAT_OPERATIONS_STRING + "\n(.*)\n\|startKeyedMsg\|", output, flags = re.DOTALL)
+        m = re.search(FRICAS_WHAT_OPERATIONS_STRING + "\n(.*)\n\\|startKeyedMsg\\|", output, flags = re.DOTALL)
         l = m.groups()[0].split()
         return l
 
@@ -511,7 +511,7 @@ class FriCAS(ExtraTabCompletion, Expect)
 
         """
         # otherwise there might be a message
-        m = re.search("\|startKeyedMsg\|\n(.*)\n\|endOfKeyedMsg\|", output, flags = re.DOTALL)
+        m = re.search("\\|startKeyedMsg\\|\n(.*)\n\\|endOfKeyedMsg\\|", output, flags = re.DOTALL)
         if m:
             replacements = [('|startKeyedMsg|\n', ''),
                             ('|endOfKeyedMsg|', '')]
@@ -568,7 +568,7 @@ class FriCAS(ExtraTabCompletion, Expect)
         """
         output = self.eval(str(var), reformat=False)
         # if there is AlgebraOutput we ask no more
-        m = re.search("\|startAlgebraOutput\|\n(.*)\n\|endOfAlgebraOutput\|", output, flags = re.DOTALL)
+        m = re.search("\\|startAlgebraOutput\\|\n(.*)\n\\|endOfAlgebraOutput\\|", output, flags = re.DOTALL)
         if m:
             lines = m.groups()[0].split("\n")
             if max(len(line) for line in lines) < FRICAS_LINE_LENGTH:
@@ -1012,10 +1012,10 @@ class FriCASElement(ExpectElement):
             sage: latex(fricas("integrate(sin(x+1/x),x)"))                      # optional - fricas
             \int ^{\displaystyle x} {{\sin \left( {{{{{ \%O} ^{2}}+1} \over  \%O}} \right)} \  {d \%O}}
         """
-        replacements = [('\sp ', '^'),
-                        ('\sp{', '^{'),
-                        ('\sb ', '_'),
-                        ('\sb{', '_{')]
+        replacements = [(r'\sp ', '^'),
+                        (r'\sp{', '^{'),
+                        (r'\sb ', '_'),
+                        (r'\sb{', '_{')]
         P = self._check_valid()
         s = P.get_string("first tex(%s)" %self._name)
         for old, new in replacements:
@@ -1081,7 +1081,7 @@ class FriCASElement(ExpectElement):
         raise NotImplementedError("The translation of FriCAS type %s to sage is not yet implemented." %domain)
 
     def _sage_expression(self, unparsed_InputForm):
-        """
+        r"""
         Convert an expression to an element of the Symbolic Ring.
 
         This does not depend on `self`.  Instead, for practical
@@ -1190,7 +1190,7 @@ class FriCASElement(ExpectElement):
 
 
     def _sage_(self):
-        """
+        r"""
         Convert self to a Sage object.
 
         EXAMPLES:
--- src/sage/interfaces/gap3.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/gap3.py	2018-10-17 14:51:21.833217076 -0600
@@ -349,8 +349,8 @@ class Gap3(Gap_generic):
         # funny-looking patterns in the interface. We compile the patterns
         # now, and use them later for interpreting interface messages.
         self._compiled_full_pattern = self._expect.compile_pattern_list([
-            '@p\d+\.','@@','@[A-Z]','@[123456!"#$%&][^+]*\+', '@e','@c',
-            '@f','@h','@i','@m','@n','@r','@s\d','@w.*\+','@x','@z'])
+            r'@p\d+\.','@@','@[A-Z]',r'@[123456!"#$%&][^+]*\+', '@e','@c',
+            '@f','@h','@i','@m','@n','@r',r'@s\d',r'@w.*\+','@x','@z'])
         self._compiled_small_pattern = self._expect.compile_pattern_list('@J')
         self._expect.expect("@i")
 
--- src/sage/interfaces/gap.py.orig	2018-08-29 11:21:43.180584324 -0600
+++ src/sage/interfaces/gap.py	2018-10-17 14:51:02.657467414 -0600
@@ -352,7 +352,7 @@ class Gap_generic(ExtraTabCompletion, Ex
         cmd = str(rnd)+';'
         try:
             E.sendline(cmd)
-            E.expect('@[nf][@J\s>]*'+str(rnd), timeout=timeout)
+            E.expect(r'@[nf][@J\s>]*'+str(rnd), timeout=timeout)
             E.send(' ')
             E.expect('@i', timeout=timeout)
         except pexpect.TIMEOUT:
@@ -404,7 +404,7 @@ class Gap_generic(ExtraTabCompletion, Ex
             # send a dummy command
             E.sendline('224433409;')
             # read everything up to the actual output of the command
-            E.expect('@[nf][@J\s>]*224433409', timeout=timeout)
+            E.expect(r'@[nf][@J\s>]*224433409', timeout=timeout)
             E.send(' ')
             # the following input prompt should be the current input
             # prompt but GAP might be too confused to display it
@@ -417,11 +417,11 @@ class Gap_generic(ExtraTabCompletion, Ex
             E.sendline()
             time.sleep(0.1)
             E.sendline('224433437;')
-            E.expect('@[nf][@J\s>]*224433437', timeout=timeout)
+            E.expect(r'@[nf][@J\s>]*224433437', timeout=timeout)
             E.sendline()
             time.sleep(0.1)
             E.sendline('224433479;')
-            E.expect('@[nf][@J\s>]*224433479', timeout=timeout)
+            E.expect(r'@[nf][@J\s>]*224433479', timeout=timeout)
             E.send(' ')
             # the following input prompt is now the current input prompt
             E.expect('@i', timeout=timeout)
@@ -674,7 +674,7 @@ class Gap_generic(ExtraTabCompletion, Ex
         raise KeyboardInterrupt("Ctrl-c pressed while running %s"%self)
 
     def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True, restart_if_needed=True):
-        """
+        r"""
         Evaluate a line of commands.
 
         REMARK:
@@ -1256,8 +1256,8 @@ class Gap(Gap_generic):
             self.save_workspace()
         # Now, as self._expect exists, we can compile some useful pattern:
         self._compiled_full_pattern = self._expect.compile_pattern_list([
-                '@p\d+\.','@@','@[A-Z]','@[123456!"#$%&][^+]*\+',
-                '@e','@c','@f','@h','@i','@m','@n','@r','@s\d','@w.*\+','@x','@z'])
+                r'@p\d+\.','@@','@[A-Z]',r'@[123456!"#$%&][^+]*\+',
+                '@e','@c','@f','@h','@i','@m','@n','@r',r'@s\d',r'@w.*\+','@x','@z'])
         # read everything up to the first "ready" prompt
         self._expect.expect("@i")
 
@@ -1359,7 +1359,7 @@ class Gap(Gap_generic):
         self.eval(r'\$SAGE.tempfile := "%s";' % tmp_to_use)
         line = Expect.eval(self, "? %s" % s)
         Expect.eval(self, "? 1")
-        match = re.search("Page from (\d+)", line)
+        match = re.search(r"Page from (\d+)", line)
         if match is None:
             print(line)
         else:
--- src/sage/interfaces/gnuplot.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/gnuplot.py	2018-10-17 14:51:44.264924229 -0600
@@ -139,7 +139,7 @@ class Gnuplot(SageObject):
                           range1='[u=-pi:pi]',
                           range2='[v=-0.2:0.2]', samples=50, title=None,
                           interact=True):
-        """
+        r"""
         Draw a parametric 3d surface and rotate it interactively.
 
         INPUT:
--- src/sage/interfaces/jmoldata.py.orig	2018-08-29 08:47:39.203938604 -0600
+++ src/sage/interfaces/jmoldata.py	2018-10-16 14:04:43.230337793 -0600
@@ -67,7 +67,7 @@ class JmolData(SageObject):
         except (subprocess.CalledProcessError, OSError):
             return False
 
-        java_version = re.search('version.*([1][.][789]|"\d+")', version)
+        java_version = re.search(r'version.*([1][.][789]|"\d+")', version)
         return java_version is not None
 
     def export_image(self,
--- src/sage/interfaces/lie.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/lie.py	2018-10-17 14:52:12.545555024 -0600
@@ -690,7 +690,7 @@ class LiE(ExtraTabCompletion, Expect):
         """
         cmd = '%s=%s'%(var,value)
         out = self.eval(cmd)
-        i = min( out.find('not defined'), out.find('\(in'), out.find('Argument types') )
+        i = min( out.find('not defined'), out.find(r'\(in'), out.find('Argument types') )
         if i != -1:
             raise RuntimeError(out)
 
--- src/sage/interfaces/macaulay2.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/macaulay2.py	2018-10-17 14:52:36.392243705 -0600
@@ -607,7 +607,7 @@ class Macaulay2(ExtraTabCompletion, Expe
 @instancedoc
 class Macaulay2Element(ExtraTabCompletion, ExpectElement):
     def _latex_(self):
-        """
+        r"""
         EXAMPLES::
 
             sage: m = macaulay2('matrix {{1,2},{3,4}}') # optional - macaulay2
--- src/sage/interfaces/magma.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/magma.py	2018-10-17 14:53:31.136529022 -0600
@@ -223,7 +223,7 @@ from .expect import console, Expect, Exp
 PROMPT = ">>>"
 
 SAGE_REF = "_sage_ref"
-SAGE_REF_RE = re.compile('%s\d+' % SAGE_REF)
+SAGE_REF_RE = re.compile(r'%s\d+' % SAGE_REF)
 
 from sage.env import SAGE_EXTCODE, DOT_SAGE
 import sage.misc.misc
@@ -2205,7 +2205,7 @@ class MagmaElement(ExtraTabCompletion, E
         return self.__gen_names
 
     def evaluate(self, *args):
-        """
+        r"""
         Evaluate self at the inputs.
 
         INPUT:
@@ -2805,10 +2805,10 @@ class MagmaGBLogPrettyPrinter:
     A device which filters Magma Groebner basis computation logs.
     """
     cmd_inpt = re.compile("^>>>$")
-    app_inpt = re.compile("^Append\(~_sage_, 0\);$")
+    app_inpt = re.compile(r"^Append\(~_sage_, 0\);$")
 
-    deg_curr = re.compile("^Basis length\: (\d+), queue length\: (\d+), step degree\: (\d+), num pairs\: (\d+)$")
-    pol_curr = re.compile("^Number of pair polynomials\: (\d+), at (\d+) column\(s\), .*")
+    deg_curr = re.compile(r"^Basis length\: (\d+), queue length\: (\d+), step degree\: (\d+), num pairs\: (\d+)$")
+    pol_curr = re.compile(r"^Number of pair polynomials\: (\d+), at (\d+) column\(s\), .*")
 
     def __init__(self, verbosity=1, style='magma'):
         """
--- src/sage/interfaces/maple.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/maple.py	2018-10-17 14:53:51.528262812 -0600
@@ -442,7 +442,7 @@ connection to a server running Maple; fo
         return self._expect
 
     def console(self):
-        """
+        r"""
         Spawn a new Maple command-line session.
 
         EXAMPLES::
@@ -1146,7 +1146,7 @@ def reduce_load_Maple():
 
 
 def maple_console():
-    """
+    r"""
     Spawn a new Maple command-line session.
 
     EXAMPLES::
--- src/sage/interfaces/mathematica.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/mathematica.py	2018-10-17 14:54:09.848023644 -0600
@@ -792,7 +792,7 @@ class MathematicaElement(ExpectElement):
 
         # Find the MMA funcs/vars/constants - they start with a letter.
         # Exclude exponents (e.g. 'e8' from 4.e8)
-        p = re.compile('(?<!\.)[a-zA-Z]\w*')
+        p = re.compile(r'(?<!\.)[a-zA-Z]\w*')
         for m in p.finditer(res):
             # If the function, variable or constant is already in the
             # translation dictionary, then just move on.
--- src/sage/interfaces/maxima_abstract.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/maxima_abstract.py	2018-10-17 14:55:16.127158376 -0600
@@ -986,7 +986,7 @@ class MaximaAbstract(ExtraTabCompletion,
         if n < 1:
             raise ValueError("n (=%s) must be >= 1" % n)
         s = repr(self('qunit(%s)' % n)).lower()
-        r = re.compile('sqrt\(.*\)')
+        r = re.compile(r'sqrt\(.*\)')
         a = QuadraticField(n, 'a').gen()
         s = r.sub('a', s)
         return eval(s)
@@ -2028,7 +2028,7 @@ class MaximaAbstractElementFunction(Maxi
         return self.definition()
 
     def _latex_(self):
-        """
+        r"""
         Return latex representation of this Maxima function.
 
         INPUT: none
--- src/sage/interfaces/maxima.py.orig	2018-08-29 08:47:09.779302448 -0600
+++ src/sage/interfaces/maxima.py	2018-10-17 14:54:44.999564744 -0600
@@ -545,7 +545,7 @@ class Maxima(MaximaAbstract, Expect):
         MaximaAbstract.__init__(self,"maxima")
         Expect.__init__(self,
                         name = 'maxima',
-                        prompt = '\(\%i[0-9]+\) ',
+                        prompt = r'\(\%i[0-9]+\) ',
                         command = 'maxima --disable-readline -p "{0}"'.format(STARTUP),
                         env = {'TMPDIR': str(ECL_TMP)},
                         script_subdirectory = script_subdirectory,
@@ -557,7 +557,7 @@ class Maxima(MaximaAbstract, Expect):
         # Must match what is in the file local/bin/sage-maxima.lisp
         self._display_prompt = '<sage-display>'
         # See #15440 for the importance of the trailing space
-        self._output_prompt_re = re.compile('\(\%o[0-9]+\) ')
+        self._output_prompt_re = re.compile(r'\(\%o[0-9]+\) ')
         self._ask = [b'zero or nonzero\\?', b'an integer\\?',
                      b'positive, negative or zero\\?', b'positive or negative\\?',
                      b'positive or zero\\?', b'equal to .*\\?']
@@ -804,7 +804,7 @@ class Maxima(MaximaAbstract, Expect):
         m = r.search(out)
         if m is not None:
             out = out[m.end():]
-        return re.sub('\s+', '', out)
+        return re.sub(r'\s+', '', out)
 
     def _synchronize(self):
         """
--- src/sage/interfaces/octave.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/octave.py	2018-10-17 14:55:41.421828157 -0600
@@ -192,7 +192,7 @@ class Octave(Expect):
         Expect.__init__(self,
                         name = 'octave',
                         # We want the prompt sequence to be unique to avoid confusion with syntax error messages containing >>>
-                        prompt = 'octave\:\d+> ',
+                        prompt = r'octave\:\d+> ',
                         # We don't want any pagination of output
                         command = command + " --no-line-editing --silent --eval 'PS2(PS1());more off' --persist",
                         maxread = maxread,
@@ -461,7 +461,7 @@ class Octave(Expect):
         octave_console()
 
     def version(self):
-        """
+        r"""
         Return the version of Octave.
 
         OUTPUT: string
--- src/sage/interfaces/phc.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/phc.py	2018-10-16 14:35:30.338352894 -0600
@@ -548,8 +548,8 @@ class PHC:
         # regular expressions for matching certain output types
         var_cnt_regex = re.compile('^ +([0-9]+)')
         output_regex  = re.compile('^OUTPUT INFORMATION DURING')
-        t_regex       = re.compile('(^t +: +(-{0,1}[0-9]+\.[0-9]+E[-+][0-9]+) +(-{0,1}[0-9]+\.[0-9]+E[-+][0-9]+)$)', re.IGNORECASE)
-        sols_regex    = re.compile('(^ *(([a-z]|[0-9])+) +: +(-?[0-9]+\.[0-9]+E[-+][0-9]+) +(-?[0-9]+\.[0-9]+E[-+][0-9]+)$)', re.IGNORECASE)
+        t_regex       = re.compile(r'(^t +: +(-{0,1}[0-9]+\.[0-9]+E[-+][0-9]+) +(-{0,1}[0-9]+\.[0-9]+E[-+][0-9]+)$)', re.IGNORECASE)
+        sols_regex    = re.compile(r'(^ *(([a-z]|[0-9])+) +: +(-?[0-9]+\.[0-9]+E[-+][0-9]+) +(-?[0-9]+\.[0-9]+E[-+][0-9]+)$)', re.IGNORECASE)
         complete_regex= re.compile('^TIMING INFORMATION')
 
         breakfast = False
--- src/sage/interfaces/polymake.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/polymake.py	2018-10-17 14:56:10.351450483 -0600
@@ -1192,7 +1192,7 @@ class Polymake(ExtraTabCompletion, Expec
             raise ValueError("Unknown polymake application '{}'".format(app))
         self._application = app
         patterns = ["{} > ".format(app),            # 0: normal prompt
-                    "{} \([0-9]+\)> ".format(app),  # 1: continuation prompt
+                    r"{} \([0-9]+\)> ".format(app), # 1: continuation prompt
                     "Please choose ".format(app),   # 2: user input expected when requesting "help"
                     "killed by signal",             # 3: what we are looking for when interrupting a computation
                     "polymake: +ERROR: +",          # 4: error
--- src/sage/interfaces/r.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/r.py	2018-10-17 14:57:14.982606727 -0600
@@ -636,9 +636,9 @@ class R(ExtraTabCompletion, Expect):
             sage: rstr.startswith('R version')
             True
         """
-        major_re = re.compile('^major\s*(\d.*?)$', re.M)
-        minor_re = re.compile('^minor\s*(\d.*?)$', re.M)
-        version_string_re = re.compile('^version.string\s*(R.*?)$', re.M)
+        major_re = re.compile(r'^major\s*(\d.*?)$', re.M)
+        minor_re = re.compile(r'^minor\s*(\d.*?)$', re.M)
+        version_string_re = re.compile(r'^version.string\s*(R.*?)$', re.M)
 
         s = self.eval('version')
 
@@ -1255,11 +1255,11 @@ class R(ExtraTabCompletion, Expect):
 
 
 # patterns for _sage_()
-rel_re_param = re.compile('\s([\w\.]+)\s=')
-rel_re_range = re.compile('([\d]+):([\d]+)')
-rel_re_integer = re.compile('([^\d])([\d]+)L')
-rel_re_terms = re.compile('terms\s*=\s*(.*?),')
-rel_re_call = re.compile('call\s*=\s*(.*?)\),')
+rel_re_param = re.compile(r'\s([\w\.]+)\s=')
+rel_re_range = re.compile(r'([\d]+):([\d]+)')
+rel_re_integer = re.compile(r'([^\d])([\d]+)L')
+rel_re_terms = re.compile(r'terms\s*=\s*(.*?),')
+rel_re_call = re.compile(r'call\s*=\s*(.*?)\),')
 
 
 @instancedoc
@@ -1676,7 +1676,7 @@ class RElement(ExtraTabCompletion, Expec
         """
         from re import compile as re_compile
         from re import split   as re_split
-        splt = re_compile('(c\(|\(|\))') # c( or ( or )
+        splt = re_compile(r'(c\(|\(|\))') # c( or ( or )
         lvl = 0
         ret = []
         for token in re_split(splt, exp):
@@ -1821,12 +1821,12 @@ class RElement(ExtraTabCompletion, Expec
 
         # Change 'structure' to '_r_structure'
         # TODO: check that we are outside of quotes ""
-        exp = re.sub(' structure\(', ' _r_structure(', exp)
-        exp = re.sub('^structure\(', '_r_structure(', exp) #special case
+        exp = re.sub(r' structure\(', ' _r_structure(', exp)
+        exp = re.sub(r'^structure\(', '_r_structure(', exp) #special case
 
         # Change 'list' to '_r_list'
-        exp = re.sub(' list\(', ' _r_list(', exp)
-        exp = re.sub('\(list\(', '(_r_list(', exp)
+        exp = re.sub(r' list\(', ' _r_list(', exp)
+        exp = re.sub(r'\(list\(', '(_r_list(', exp)
 
         # Change 'a:b' to 'range(a,b+1)'
         exp = rel_re_range.sub(self._subs_range, exp)
--- src/sage/interfaces/rubik.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/interfaces/rubik.py	2018-10-16 14:36:13.017821504 -0600
@@ -209,14 +209,14 @@ class CubexSolver:
         """
         s = self.format_cube(facets)
         child = pexpect.spawn(self.__cmd+" "+s)
-        ix = child.expect(['210.*?:', '^5\d+(.*)'])
+        ix = child.expect(['210.*?:', r'^5\d+(.*)'])
         if ix == 0:
             child.expect(['211', pexpect.EOF])
             moves = bytes_to_str(child.before).strip().replace(',', '').split(' ')
             return " ".join([move_map[m] for m in reversed(moves)])
         else:
             s = child.after
-            while child.expect(['^5\d+', pexpect.EOF]) == 0:
+            while child.expect([r'^5\d+', pexpect.EOF]) == 0:
                 s += child.after
             raise ValueError(bytes_to_str(s))
 
--- src/sage/interfaces/singular.py.orig	2018-08-29 08:36:07.818487766 -0600
+++ src/sage/interfaces/singular.py	2018-10-17 14:59:43.460668361 -0600
@@ -1113,7 +1113,7 @@ class Singular(ExtraTabCompletion, Expec
             True
         """
         ringlist = self.eval("listvar(ring)").splitlines()
-        p = re.compile("// ([a-zA-Z0-9_]*).*\[.*\].*\*.*") #do this in constructor?
+        p = re.compile(r"// ([a-zA-Z0-9_]*).*\[.*\].*\*.*") #do this in constructor?
         for line in ringlist:
             m = p.match(line)
             if m:
@@ -1164,7 +1164,7 @@ class Singular(ExtraTabCompletion, Expec
         return [p.match(line).group(int(1)) for line in proclist]
 
     def console(self):
-        """
+        r"""
         EXAMPLES::
 
             sage: singular_console() #not tested
@@ -2019,7 +2019,7 @@ class SingularElement(ExtraTabCompletion
             ['0', 'x', 'y', 'dp', '1,1', 'C', '0', '_[1]=0']
         """
         s = str(self)
-        c = '\[[0-9]*\]:'
+        c = r'\[[0-9]*\]:'
         r = re.compile(c)
         s = r.sub('',s).strip()
         return s.split()
@@ -2090,7 +2090,7 @@ class SingularElement(ExtraTabCompletion
             'poly'
         """
         # singular reports // $varname $type $stuff
-        p = re.compile("// [\w]+ (\w+) [\w]*")
+        p = re.compile(r"// [\w]+ (\w+) [\w]*")
         m = p.match(self.parent().eval("type(%s)"%self.name()))
         return m.group(1)
 
@@ -2264,8 +2264,8 @@ def generate_docstring_dictionary():
 
     singular_docdir = os.environ["SINGULAR_BIN_DIR"]+"/info/"
 
-    new_node = re.compile("File: singular\.hlp,  Node: ([^,]*),.*")
-    new_lookup = re.compile("\* ([^:]*):*([^.]*)\..*")
+    new_node = re.compile(r"File: singular\.hlp,  Node: ([^,]*),.*")
+    new_lookup = re.compile(r"\* ([^:]*):*([^.]*)\..*")
 
     L, in_node, curr_node = [], False, None
 
@@ -2333,7 +2333,7 @@ def reduce_load_Singular():
 
 
 def singular_console():
-    """
+    r"""
     Spawn a new Singular command-line session.
 
     EXAMPLES::
@@ -2369,30 +2369,30 @@ class SingularGBLogPrettyPrinter:
     A device which prints Singular Groebner basis computation logs
     more verbatim.
     """
-    rng_chng = re.compile("\[\d+:\d+\]")# [m:n] internal ring change to
+    rng_chng = re.compile(r"\[\d+:\d+\]")# [m:n] internal ring change to
                                         # poly representation with
                                         # exponent bound m and n words in
                                         # exponent vector
     new_elem = re.compile("s")          # found a new element of the standard basis
     red_zero = re.compile("-")          # reduced a pair/S-polynomial to 0
-    red_post = re.compile("\.")         # postponed a reduction of a pair/S-polynomial
+    red_post = re.compile(r"\.")        # postponed a reduction of a pair/S-polynomial
     cri_hilb = re.compile("h")          # used Hilbert series criterion
-    hig_corn = re.compile("H\(\d+\)")   # found a 'highest corner' of degree d, no need to consider higher degrees
-    num_crit = re.compile("\(\d+\)")    # n critical pairs are still to be reduced
-    red_num =  re.compile("\(S:\d+\)")  # doing complete reduction of n elements
-    deg_lead = re.compile("\d+")        # the degree of the leading terms is currently d
+    hig_corn = re.compile(r"H\(\d+\)")  # found a 'highest corner' of degree d, no need to consider higher degrees
+    num_crit = re.compile(r"\(\d+\)")   # n critical pairs are still to be reduced
+    red_num =  re.compile(r"\(S:\d+\)") # doing complete reduction of n elements
+    deg_lead = re.compile(r"\d+")       # the degree of the leading terms is currently d
 
     # SlimGB
-    red_para = re.compile("M\[(\d+),(\d+)\]") # parallel reduction of n elements with m non-zero output elements
+    red_para = re.compile(r"M\[(\d+),(\d+)\]")# parallel reduction of n elements with m non-zero output elements
     red_betr = re.compile("b")                # exchange of a reductor by a 'better' one
     non_mini = re.compile("e")                # a new reductor with non-minimal leading term
 
-    crt_lne1 = re.compile("product criterion:(\d+) chain criterion:(\d+)")
-    crt_lne2 = re.compile("NF:(\d+) product criterion:(\d+), ext_product criterion:(\d+)")
+    crt_lne1 = re.compile(r"product criterion:(\d+) chain criterion:(\d+)")
+    crt_lne2 = re.compile(r"NF:(\d+) product criterion:(\d+), ext_product criterion:(\d+)")
 
-    pat_sync = re.compile("1\+(\d+);")
+    pat_sync = re.compile(r"1\+(\d+);")
 
-    global_pattern = re.compile("(\[\d+:\d+\]|s|-|\.|h|H\(\d+\)|\(\d+\)|\(S:\d+\)|\d+|M\[\d+,[b,e]*\d+\]|b|e).*")
+    global_pattern = re.compile(r"(\[\d+:\d+\]|s|-|\.|h|H\(\d+\)|\(\d+\)|\(S:\d+\)|\d+|M\[\d+,[b,e]*\d+\]|b|e).*")
 
     def __init__(self, verbosity=1):
         """
--- src/sage/manifolds/differentiable/tensorfield.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/manifolds/differentiable/tensorfield.py	2018-10-16 14:01:26.617775475 -0600
@@ -1212,7 +1212,7 @@ class TensorField(ModuleElement):
             resu[[ind]] = dom.scalar_field({chart: scomp[[ind]].expr(schart)})
 
     def add_expr_from_subdomain(self, frame, subdomain):
-        """
+        r"""
         Add an expression to an existing component from a subdomain.
 
         INPUT:
--- src/sage/manifolds/structure.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/manifolds/structure.py	2018-10-16 14:00:51.066216259 -0600
@@ -61,7 +61,7 @@ class TopologicalStructure(Singleton):
         return cat
 
 class RealTopologicalStructure(Singleton):
-    """
+    r"""
     The structure of a topological manifold over `\RR`.
     """
     chart = RealChart
@@ -110,7 +110,7 @@ class DifferentialStructure(Singleton):
         return cat
 
 class RealDifferentialStructure(Singleton):
-    """
+    r"""
     The structure of a differentiable manifold over `\RR`.
     """
     chart = RealDiffChart
--- src/sage/manifolds/utilities.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/manifolds/utilities.py	2018-10-16 13:59:15.603399845 -0600
@@ -1066,22 +1066,22 @@ class ExpressionNice(Expression):
             # checking if the variable is composite
             for i, val in enumerate(strv):
                 if bool(re.search(r'[+|-|/|*|^|(|)]', val)):
-                    latv[i] = "\left(" + latv[i] + "\\right)"
+                    latv[i] = "\\left(" + latv[i] + "\\right)"
 
             # dictionary to group multiple occurrences of differentiation: d/dxdx -> d/dx^2 etc.
             occ = {i: (latv[i] + "^" + latex(diffargs.count(i))
                        if diffargs.count(i) > 1 else latv[i])
                    for i in diffargs}
 
-            res = "\\frac{\partial" + numargs + "\," + funcname + \
-                  "}{\partial " + "\partial ".join(i for i in occ.values()) + "}"
+            res = "\\frac{\\partial" + numargs + "\\," + funcname + \
+                  "}{\\partial " + "\\partial ".join(i for i in occ.values()) + "}"
 
             # representation of the operator
             s = self._parent._latex_element_(m[0])
 
             # if diff operator is raised to some power (m[5]), put brackets around
             if m[5]:
-                res = "\left(" + res + "\\right)^{" + str(m[5]) + "}"
+                res = "\\left(" + res + "\\right)^{" + str(m[5]) + "}"
                 o = s + "^{" + str(m[5]) + "}"
             else:
                 o = s
--- src/sage/matroids/catalog.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/matroids/catalog.py	2018-10-16 14:38:19.688244377 -0600
@@ -155,7 +155,7 @@ def R6():
 
 
 def Fano():
-    """
+    r"""
     Return the Fano matroid, represented over `GF(2)`.
 
     The Fano matroid, or Fano plane, or `F_7`, is a 7-element matroid of
@@ -774,7 +774,7 @@ def CompleteGraphic(n):
 
 
 def Wheel(n, field=None, ring=None):
-    """
+    r"""
     Return the rank-`n` wheel.
 
     INPUT:
@@ -979,7 +979,7 @@ def PG(n, q, x=None):
 
 
 def AG(n, q, x=None):
-    """
+    r"""
     Return the affine geometry of dimension ``n`` over the finite field of
     order ``q``.
 
@@ -1233,7 +1233,7 @@ def TicTacToe():
 
 
 def Q10():
-    """
+    r"""
     Return the matroid `Q_{10}`, represented over `\GF{4}`.
 
     `Q_{10}` is a 10-element, rank-5, self-dual matroid. It is representable
@@ -1273,7 +1273,7 @@ def Q10():
 
 
 def N1():
-    """
+    r"""
     Return the matroid `N_1`, represented over `\GF{3}`.
 
     `N_1` is an excluded minor for the dyadic matroids. See [Oxl2011]_, p. 554.
@@ -1300,7 +1300,7 @@ def N1():
 
 
 def N2():
-    """
+    r"""
     Return the matroid `N_2`, represented over `\GF{3}`.
 
     `N_2` is an excluded minor for the dyadic matroids. See [Oxl2011]_, p. 554.
--- src/sage/matroids/dual_matroid.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/matroids/dual_matroid.py	2018-10-16 14:38:41.247975942 -0600
@@ -355,7 +355,7 @@ class DualMatroid(Matroid):
         return DualMatroid(self._matroid._minor(contractions=deletions, deletions=contractions))
 
     def dual(self):
-        """
+        r"""
         Return the dual of the matroid.
 
         Let `M` be a matroid with ground set `E`. If `B` is the set of bases
--- src/sage/matroids/matroids_plot_helpers.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/matroids/matroids_plot_helpers.py	2018-10-16 14:40:05.662924917 -0600
@@ -81,7 +81,7 @@ from sage.matroids.advanced import newla
 
 
 def it(M, B1, nB1, lps):
-    """
+    r"""
     Return points on and off the triangle and lines to be drawn for a rank 3
     matroid.
 
--- src/sage/matroids/minor_matroid.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/matroids/minor_matroid.py	2018-10-16 14:39:22.031468163 -0600
@@ -362,7 +362,7 @@ class MinorMatroid(Matroid):
         if len(self._contractions) > 0:
             s = s + " / " + setprint_s(self._contractions, toplevel=True)
         if len(self._deletions) > 0:
-            s = s + " \ " + setprint_s(self._deletions, toplevel=True)
+            s = s + " \\ " + setprint_s(self._deletions, toplevel=True)
         s += ", where M is " + repr(self._matroid)
         return s
 
@@ -511,7 +511,7 @@ class MinorMatroid(Matroid):
         return N
 
     def __reduce__(self):
-        """
+        r"""
         Save the matroid for later reloading.
 
         EXAMPLES::
--- src/sage/matroids/utilities.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/matroids/utilities.py	2018-10-16 14:37:32.024837814 -0600
@@ -651,7 +651,7 @@ def lift_cross_ratios(A, lift_map = None
     return Z
 
 def lift_map(target):
-    """
+    r"""
     Create a lift map, to be used for lifting the cross ratios of a matroid
     representation.
 
--- src/sage/misc/dev_tools.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/misc/dev_tools.py	2018-10-17 14:14:30.691760445 -0600
@@ -177,7 +177,7 @@ def load_submodules(module=None, exclude
     if module is None:
         import sage
         module = sage
-        exclude_pattern = "^sage\.libs|^sage\.tests|tests$|^sage\.all_|all$|sage\.interacts$|^sage\.misc\.benchmark$"
+        exclude_pattern = r"^sage\.libs|^sage\.tests|tests$|^sage\.all_|all$|sage\.interacts$|^sage\.misc\.benchmark$"
 
     if exclude_pattern:
         import re
@@ -314,7 +314,7 @@ def find_object_modules(obj):
 
     # if the object is an instance, we try to guess where it is defined
     if sageinspect.isclassinstance(obj):
-        dec_pattern = re.compile("^(\w[\w0-9\_]*)\s*=", re.MULTILINE)
+        dec_pattern = re.compile(r"^(\w[\w0-9\_]*)\s*=", re.MULTILINE)
         module_to_obj2 = {}
         for module_name, obj_names in iteritems(module_to_obj):
             module_to_obj2[module_name] = []
--- src/sage/misc/latex.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/misc/latex.py	2018-10-17 14:16:12.387449261 -0600
@@ -259,7 +259,7 @@ def builtin_constant_function(x):
     """
     if EMBEDDED_MODE:
         return "{\\rm %s}"%x
-    return "\mbox{\\rm %s}"%x
+    return "\\mbox{\\rm %s}"%x
 
 def None_function(x):
     r"""
@@ -329,7 +329,7 @@ def str_function(x):
         return x
     # Deal with special characters
     char_wrapper = r"{\char`\%s}"
-    x = "".join(char_wrapper % c if c in "#$%&\^_{}~" else c for c in x)
+    x = "".join(char_wrapper % c if c in r"#$%&\^_{}~" else c for c in x)
     # Avoid grouping spaces into one
     x = x.replace(" ", "{ }")
     # And dashes too, since it causes issues for the command line...
@@ -865,7 +865,7 @@ def _run_latex_(filename, debug=False, d
     return return_suffix
 
 class LatexCall:
-    """
+    r"""
     Typeset Sage objects via a ``__call__`` method to this class,
     typically by calling those objects' ``_latex_`` methods.  The
     class :class:`Latex` inherits from this. This class is used in
@@ -1963,7 +1963,7 @@ class MathJax:
             # part should end in "}}", so omit the last two characters
             # from y
             y = part[:closing-1]
-            for delimiter in """|"'`#%&,.:;?!@_~^+-/\=<>()[]{}0123456789E""":
+            for delimiter in r"""|"'`#%&,.:;?!@_~^+-/\=<>()[]{}0123456789E""":
                 if delimiter not in y:
                     break
             if delimiter == "E":
@@ -2419,7 +2419,7 @@ def repr_lincomb(symbols, coeffs):
                 # multiplication sign in
                 try:
                     if bv in CC:
-                        s += "%s\cdot %s" % (coeff, b)
+                        s += "%s\\cdot %s" % (coeff, b)
                     else:
                         s += "%s%s" % (coeff, b)
                 except Exception:
@@ -2614,7 +2614,7 @@ def latex_variable_name(x, is_fname=Fals
         # * The "\d|[.,]" means "decimal digit" or period or comma
         # * The "+" means "1 or more"
         # * The "$" means "at the end of the line"
-        m = re.search('(\d|[.,])+$',x)
+        m = re.search(r'(\d|[.,])+$',x)
         if m is None:
             prefix = x
             suffix = None
--- src/sage/misc/misc.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/misc/misc.py	2018-10-17 14:17:02.905797916 -0600
@@ -903,7 +903,7 @@ def assert_attribute(x, attr, init=None)
 
 
 def compose(f, g):
-    """
+    r"""
     Return the composition of one-variable functions: `f \circ g`
 
     See also :func:`nest()`
@@ -1040,10 +1040,10 @@ def nest(f, n, x):
 #################################################################
 
 class BackslashOperator:
-    """
+    r"""
     Implements Matlab-style backslash operator for solving systems::
 
-        A \\ b
+        A \ b
 
     The preparser converts this to multiplications using
     ``BackslashOperator()``.
@@ -1080,7 +1080,7 @@ class BackslashOperator:
         return self
 
     def __mul__(self, right):
-        """
+        r"""
         EXAMPLES::
 
             sage: A = matrix(RDF, 5, 5, 2)
--- src/sage/misc/sagedoc.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/misc/sagedoc.py	2018-10-16 14:02:58.664634242 -0600
@@ -324,7 +324,7 @@ def skip_TESTS_block(docstring):
     # underscores.
     # Also match uppercase text followed by a colon, like
     # "REFERENCES:" or "ALGORITHM:".
-    end_of_block = re.compile('[ ]*(\.\.[ ]+[-_A-Za-z]+|[A-Z]+):')
+    end_of_block = re.compile(r'[ ]*(\.\.[ ]+[-_A-Za-z]+|[A-Z]+):')
     # header: match a string of hyphens, or other characters which are
     # valid markers for reST headers: - = ` : ' " ~ _ ^ * + # < >
     header = re.compile(r'^[ ]*([-=`:\'"~_^*+#><])\1+[ ]*$')
@@ -915,7 +915,7 @@ You can build this with 'sage -docbuild
     # done with preparation; ready to start search
     for dirpath, dirs, files in os.walk(os.path.join(base_path, module)):
         for f in files:
-            if not f.startswith('.') and re.search("\.(" + "|".join(exts) + ")$", f):
+            if not f.startswith('.') and re.search("\\.(" + "|".join(exts) + ")$", f):
                 filename = os.path.join(dirpath, f)
                 if re.search(path_re, filename):
                     if multiline:
--- src/sage/misc/sphinxify.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/misc/sphinxify.py	2018-10-16 14:03:56.390918527 -0600
@@ -108,7 +108,7 @@ smart_quotes = no
         #    "/media/...path.../blah.png"
         # to
         #    "/doc/static/reference/media/...path.../blah.png"
-        output = re.sub("""src=['"](/?\.\.)*/?media/([^"']*)['"]""",
+        output = re.sub("""src=['"](/?\\.\\.)*/?media/([^"']*)['"]""",
                           'src="/doc/static/reference/media/\\2"',
                           output)
         # Remove spurious \(, \), \[, \].
--- src/sage/modular/abvar/abvar.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/abvar/abvar.py	2018-10-17 14:24:07.958317626 -0600
@@ -231,7 +231,7 @@ class ModularAbelianVariety_abstract(Par
     #############################################################################
     # lattice() *must* be defined by every derived class!!!!
     def lattice(self):
-        """
+        r"""
         Return lattice in ambient cuspidal modular symbols product that
         defines this modular abelian variety.
 
@@ -4178,7 +4178,7 @@ class ModularAbelianVariety_modsym_abstr
         return M
 
     def _compute_hecke_polynomial(self, n, var='x'):
-        """
+        r"""
         Return the characteristic polynomial of the `n^{th}` Hecke
         operator on self.
 
--- src/sage/modular/abvar/morphism.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/abvar/morphism.py	2018-10-17 14:24:24.980098164 -0600
@@ -898,7 +898,7 @@ class HeckeOperator(Morphism):
         return self.__abvar.homology(R).hecke_operator(self.index())
 
     def matrix(self):
-        """
+        r"""
         Return the matrix of self acting on the homology
         `H_1(A, ZZ)` of this abelian variety with coefficients in
         `\ZZ`.
--- src/sage/modular/arithgroup/congroup_generic.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/arithgroup/congroup_generic.py	2018-10-17 14:12:02.381670997 -0600
@@ -111,7 +111,7 @@ def CongruenceSubgroup_constructor(*args
         return CongruenceSubgroupFromGroup(GG)
 
 def is_CongruenceSubgroup(x):
-    """
+    r"""
     Return True if x is of type CongruenceSubgroup.
 
     Note that this may be False even if `x` really is a congruence subgroup --
--- src/sage/modular/btquotients/btquotient.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/btquotients/btquotient.py	2018-10-17 14:30:59.593010312 -0600
@@ -1842,7 +1842,7 @@ class BruhatTitsQuotient(SageObject, Uni
 
     @cached_method
     def get_num_verts(self):
-        """
+        r"""
         Return the number of vertices in the quotient using the formula
         `V = 2(\mu/12 + e_3/3 + e_4/4)`.
 
@@ -3284,7 +3284,7 @@ class BruhatTitsQuotient(SageObject, Uni
             return stabs
 
     def _nebentype_check(self, vec, twom, E, A, flag = 2):
-        """
+        r"""
         Check if a quaternion maps into a subgroup of matrices
         determined by a nontrivial Dirichlet character (associated to
         self). If `N^+ = 1` then the condition is trivially satisfied.
--- src/sage/modular/buzzard.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/buzzard.py	2018-10-17 14:28:35.592866947 -0600
@@ -71,7 +71,7 @@ def gp():
 
 
 def buzzard_tpslopes(p, N, kmax):
-    """
+    r"""
     Returns a vector of length kmax, whose `k`'th entry
     (`0 \leq k \leq k_{max}`) is the conjectural sequence
     of valuations of eigenvalues of `T_p` on forms of level
--- src/sage/modular/cusps_nf.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/cusps_nf.py	2018-10-17 14:29:24.465236820 -0600
@@ -334,7 +334,7 @@ class NFCuspsSpace(ParentWithBase):
         return "Set of all cusps of %s" % self.number_field()
 
     def _latex_(self):
-        """
+        r"""
         Return latex representation of self.
 
         EXAMPLES::
--- src/sage/modular/cusps.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/cusps.py	2018-10-17 14:29:08.312445082 -0600
@@ -113,7 +113,7 @@ class Cusps_class(ParentWithBase):
         return "Set P^1(QQ) of all cusps"
 
     def _latex_(self):
-        """
+        r"""
         Return latex representation of self.
 
         EXAMPLES::
@@ -854,7 +854,7 @@ class Cusp(Element):
         return False, 0
 
     def is_gamma_h_equiv(self, other, G):
-        """
+        r"""
         Return a pair (b, t), where b is True or False as self and other
         are equivalent under the action of G, and t is 1 or -1, as
         described below.
--- src/sage/modular/dirichlet.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/dirichlet.py	2018-10-17 14:29:58.280800826 -0600
@@ -761,7 +761,7 @@ class DirichletCharacter(MultiplicativeG
 
     @cached_method
     def decomposition(self):
-        """
+        r"""
         Return the decomposition of self as a product of Dirichlet
         characters of prime power modulus, where the prime powers exactly
         divide the modulus of this character.
@@ -1059,7 +1059,7 @@ class DirichletCharacter(MultiplicativeG
         return g
 
     def jacobi_sum(self, char, check=True):
-        """
+        r"""
         Return the Jacobi sum associated to these Dirichlet characters
         (i.e., J(self,char)). This is defined as
 
--- src/sage/modular/etaproducts.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/etaproducts.py	2018-10-17 14:30:17.537552545 -0600
@@ -787,7 +787,7 @@ class CuspFamily(SageObject):
         return self._N
 
     def sage_cusp(self):
-        """
+        r"""
         Return the corresponding element of
         `\mathbb{P}^1(\QQ)`.
 
--- src/sage/modular/hecke/algebra.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/hecke/algebra.py	2018-10-17 14:22:50.750313091 -0600
@@ -690,7 +690,7 @@ class HeckeAlgebra_anemic(HeckeAlgebra_b
         return True
 
     def gens(self):
-        """
+        r"""
         Return a generator over all Hecke operator `T_n` for
         `n = 1, 2, 3, \ldots`, with `n` coprime to the
         level. This is an infinite sequence.
--- src/sage/modular/hecke/module.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/hecke/module.py	2018-10-17 14:23:12.430033569 -0600
@@ -1227,7 +1227,7 @@ class HeckeModule_free_module(HeckeModul
         return self._dual_hecke_matrices[n]
 
     def eigenvalue(self, n, name='alpha'):
-        """
+        r"""
         Assuming that self is a simple space, return the eigenvalue of the
         `n^{th}` Hecke operator on self.
 
--- src/sage/modular/hecke/submodule.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/hecke/submodule.py	2018-10-17 14:23:28.788822652 -0600
@@ -843,7 +843,7 @@ class HeckeSubmodule(module.HeckeModule_
         return self.free_module().nonembedded_free_module()
 
     def old_submodule(self, p=None):
-        """
+        r"""
         Return the old or p-old submodule of this space of modular
         symbols.
 
--- src/sage/modular/modform/ambient_g0.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modform/ambient_g0.py	2018-10-17 14:24:54.883712606 -0600
@@ -28,7 +28,7 @@ from . import eisenstein_submodule
 from sage.misc.cachefunc import cached_method
 
 class ModularFormsAmbient_g0_Q(ambient.ModularFormsAmbient):
-    """
+    r"""
     A space of modular forms for `\Gamma_0(N)` over `\QQ`.
     """
     def __init__(self, level, weight):
--- src/sage/modular/modform/ambient_g1.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modform/ambient_g1.py	2018-10-17 14:25:18.772404601 -0600
@@ -60,7 +60,7 @@ from . import cuspidal_submodule
 from . import eisenstein_submodule
 
 class ModularFormsAmbient_gH_Q(ambient.ModularFormsAmbient):
-    """
+    r"""
     A space of modular forms for the group `\Gamma_H(N)` over the rational numbers.
     """
     def __init__(self, group, weight, eis_only):
@@ -156,7 +156,7 @@ class ModularFormsAmbient_gH_Q(ambient.M
 
 
 class ModularFormsAmbient_g1_Q(ModularFormsAmbient_gH_Q):
-    """
+    r"""
     A space of modular forms for the group `\Gamma_1(N)` over the rational numbers.
     """
     def __init__(self, level, weight, eis_only):
--- src/sage/modular/modform/eisenstein_submodule.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modform/eisenstein_submodule.py	2018-10-17 14:26:41.179342109 -0600
@@ -513,7 +513,7 @@ class EisensteinSubmodule_g1_Q(Eisenstei
     Space of Eisenstein forms for `\Gamma_1(N)`.
     """
     def _parameters_character(self):
-        """
+        r"""
         Return the character defining self. Since self is a space of Eisenstein
         forms on `\Gamma_1(N)`, all characters modulo the level are possible,
         so we return the level.
@@ -607,7 +607,7 @@ def cyclotomic_restriction(L,K):
         M = CyclotomicField(lcm(L.zeta_order(), K.zeta_order()))
         f = cyclotomic_restriction_tower(M,K)
         def g(x):
-            """
+            r"""
             Function returned by cyclotomic restriction.
 
             INPUT:
@@ -665,7 +665,7 @@ def cyclotomic_restriction_tower(L,K):
     g = R(f)
     h_ls = [ t[0] for t in g.factor() if t[0](L.gen(0)) == 0 ]
     if len(h_ls) == 0:
-        raise ValueError("K (= Q(\zeta_%s)) is not contained in L (= Q(\zeta_%s))"%(K._n(), L._n()))
+        raise ValueError(r"K (= Q(\zeta_%s)) is not contained in L (= Q(\zeta_%s))"%(K._n(), L._n()))
     h = h_ls[0]
     def z(a):
         """
--- src/sage/modular/modform/eis_series.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modform/eis_series.py	2018-10-17 14:25:59.178883627 -0600
@@ -198,7 +198,7 @@ def __common_minimal_basering(chi, psi):
 #    return eps.primitive_character()
 
 def __find_eisen_chars(character, k):
-    """
+    r"""
     Find all triples `(\psi_1, \psi_2, t)` that give rise to an Eisenstein series of the given weight and character.
 
     EXAMPLES::
@@ -288,7 +288,7 @@ def __find_eisen_chars(character, k):
     return params
 
 def __find_eisen_chars_gammaH(N, H, k):
-    """
+    r"""
     Find all triples `(\psi_1, \psi_2, t)` that give rise to an Eisenstein series of weight `k` on
     `\Gamma_H(N)`.
 
@@ -305,7 +305,7 @@ def __find_eisen_chars_gammaH(N, H, k):
     return params
 
 def __find_eisen_chars_gamma1(N, k):
-    """
+    r"""
     Find all triples `(\psi_1, \psi_2, t)` that give rise to an Eisenstein series of weight `k` on
     `\Gamma_1(N)`.
 
--- src/sage/modular/modform/element.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modform/element.py	2018-10-17 14:27:08.819985729 -0600
@@ -1766,7 +1766,7 @@ class Newform(ModularForm_abstract):
         return w / Q0 / sign * self.character()(crt(1, Q//Q0, Q, N//Q))
 
     def atkin_lehner_action(self, d=None, normalization='analytic', embedding=None):
-        """
+        r"""
         Return the result of the Atkin-Lehner operator `W_d` on this form `f`,
         in the form of a constant `\lambda_d(f)` and a normalized newform `f'`
         such that
@@ -2751,7 +2751,7 @@ class EisensteinSeries(ModularFormElemen
         return v
 
     def __compute_general_case(self, X):
-        """
+        r"""
         Returns the list coefficients of `q^n` of the power series of self,
         for `n` in the list `X`.  The results are not cached.  (Use
         coefficients for cached results).
--- src/sage/modular/modform_hecketriangle/abstract_space.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modform_hecketriangle/abstract_space.py	2018-10-16 14:42:57.389786793 -0600
@@ -121,7 +121,7 @@ class FormsSpace_abstract(FormsRing_abst
         """
 
         from sage.misc.latex import latex
-        return "{}_{{ n={} }}({},\ {})({})".format(self._analytic_type.latex_space_name(), self._group.n(), self._weight, self._ep, latex(self._base_ring))
+        return r"{}_{{ n={} }}({},\ {})({})".format(self._analytic_type.latex_space_name(), self._group.n(), self._weight, self._ep, latex(self._base_ring))
 
     def _element_constructor_(self, el):
         r"""
--- src/sage/modular/modform/space.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modform/space.py	2018-10-17 14:27:32.002686826 -0600
@@ -291,7 +291,7 @@ class ModularFormsSpace(hecke.HeckeModul
         return self.__group
 
     def character(self):
-        """
+        r"""
         Return the Dirichlet character corresponding to this space of
         modular forms. Returns None if there is no specific character
         corresponding to this space, e.g., if this is a space of modular
@@ -332,7 +332,7 @@ class ModularFormsSpace(hecke.HeckeModul
         return self.__character
 
     def has_character(self):
-        """
+        r"""
         Return True if this space of modular forms has a specific
         character.
 
--- src/sage/modular/modform/vm_basis.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modform/vm_basis.py	2018-10-17 14:28:10.282193280 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 The Victor Miller Basis
 
 This module contains functions for quick calculation of a basis of
@@ -266,7 +266,7 @@ def _delta_poly(prec=10):
     return f
 
 def _delta_poly_modulo(N, prec=10):
-    """
+    r"""
     Return the q-expansion of `\Delta` modulo `N`. Used internally by
     the :func:`~delta_qexp` function. See the docstring of :func:`~delta_qexp`
     for more information.
@@ -322,7 +322,7 @@ def _delta_poly_modulo(N, prec=10):
 
 
 def delta_qexp(prec=10, var='q', K=ZZ) :
-    """
+    r"""
     Return the `q`-expansion of the weight 12 cusp form `\Delta` as a power
     series with coefficients in the ring K (`= \ZZ` by default).
 
--- src/sage/modular/modsym/ambient.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modsym/ambient.py	2018-10-16 14:43:55.845058982 -0600
@@ -3551,7 +3551,7 @@ class ModularSymbolsAmbient_wtk_eps(Modu
         return m * self.group().dimension_new_cusp_forms(self.weight(), eps=self.character())
 
     def _matrix_of_operator_on_modular_symbols(self, codomain, R, character_twist=False):
-        """
+        r"""
         INPUT:
 
 
--- src/sage/modular/modsym/boundary.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modsym/boundary.py	2018-10-16 14:45:01.452242129 -0600
@@ -222,7 +222,7 @@ class BoundarySpaceElement(hecke.HeckeMo
         return BoundarySpaceElement(self.parent(), z)
 
     def _rmul_(self, other):
-        """
+        r"""
         Return self \* other. Assumes that other can be coerced into
         self.parent().base_ring().
 
@@ -241,7 +241,7 @@ class BoundarySpaceElement(hecke.HeckeMo
         return BoundarySpaceElement(self.parent(), x)
 
     def _lmul_(self, other):
-        """
+        r"""
         Return other \* self. Assumes that other can be coerced into
         self.parent().base_ring().
 
--- src/sage/modular/modsym/element.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modsym/element.py	2018-10-17 14:31:22.686712491 -0600
@@ -43,7 +43,7 @@ def is_ModularSymbolsElement(x):
     return isinstance(x, ModularSymbolsElement)
 
 def set_modsym_print_mode(mode="manin"):
-    """
+    r"""
     Set the mode for printing of elements of modular symbols spaces.
 
     INPUT:
--- src/sage/modular/modsym/manin_symbol_list.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modsym/manin_symbol_list.py	2018-10-16 14:44:16.915796635 -0600
@@ -799,7 +799,7 @@ class ManinSymbolList_gamma1(ManinSymbol
         True
     """
     def __init__(self, level, weight):
-        """
+        r"""
         Constructor for a ModularSymbolList for `\Gamma_0(N)`.
 
         EXAMPLES::
--- src/sage/modular/modsym/p1list_nf.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modsym/p1list_nf.py	2018-10-17 14:33:10.175326094 -0600
@@ -234,7 +234,7 @@ class MSymbol(SageObject):
             sage: latex(alpha) # indirect doctest
             \(3: 5 a^{2} - 1\)
         """
-        return "\\(%s: %s\)"%(self.c._latex_(), self.d._latex_())
+        return "\\(%s: %s\\)"%(self.c._latex_(), self.d._latex_())
 
     def __richcmp__(self, other, op):
         """
@@ -362,7 +362,7 @@ class MSymbol(SageObject):
         return lift_to_sl2_Ok(self.__N, self.__c, self.__d)
 
     def normalize(self, with_scalar=False):
-        """
+        r"""
         Returns a normalized MSymbol (a canonical representative of an element
         of `\mathbb{P}^1(R/N)` ) equivalent to ``self``.
 
@@ -460,7 +460,7 @@ class MSymbol(SageObject):
 
 @richcmp_method
 class P1NFList(SageObject):
-    """
+    r"""
     The class for `\mathbb{P}^1(R/N)`, the projective line modulo `N`, where
     `R` is the ring of integers of a number field `K` and `N` is an integral ideal.
 
@@ -588,7 +588,7 @@ class P1NFList(SageObject):
         return self.__list
 
     def normalize(self, c, d=None, with_scalar=False):
-        """
+        r"""
         Returns a normalised element of `\mathbb{P}^1(R/N)`.
 
         INPUT:
@@ -657,7 +657,7 @@ class P1NFList(SageObject):
         return self.__N
 
     def index(self, c, d=None, with_scalar=False):
-        """
+        r"""
         Returns the index of the class of the pair `(c, d)` in the fixed list
         of representatives of `\mathbb{P}^1(R/N)`.
 
@@ -740,7 +740,7 @@ class P1NFList(SageObject):
         return False
 
     def index_of_normalized_pair(self, c, d=None):
-        """
+        r"""
         Returns the index of the class `(c, d)` in the fixed list of
         representatives of `\mathbb(P)^1(R/N)`.
 
@@ -918,7 +918,7 @@ class P1NFList(SageObject):
         return j
 
     def apply_J_epsilon(self, i, e1, e2=1):
-        """
+        r"""
         Applies the matrix `J_{\epsilon}` = [e1, 0, 0, e2] to the i-th
         M-Symbol of the list.
 
@@ -1171,7 +1171,7 @@ def make_coprime(N, c, d):
         return c, d1
 
 def psi(N):
-    """
+    r"""
     The index `[\Gamma : \Gamma_0(N)]`, where `\Gamma = GL(2, R)` for `R` the
     corresponding ring of integers, and `\Gamma_0(N)` standard congruence
     subgroup.
--- src/sage/modular/modsym/relation_matrix.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modsym/relation_matrix.py	2018-10-16 14:46:13.530344702 -0600
@@ -59,7 +59,7 @@ from sage.modular.modsym.manin_symbol_li
 # of that function for an overall description of the algorithm.
 ######################################################################
 def modS_relations(syms):
-    """
+    r"""
     Compute quotient of Manin symbols by the S relations.
 
     Here S is the 2x2 matrix [0, -1; 1, 0].
@@ -131,7 +131,7 @@ def modS_relations(syms):
     return rels
 
 def modI_relations(syms, sign):
-    """
+    r"""
     Compute quotient of Manin symbols by the I relations.
 
     INPUT:
--- src/sage/modular/modsym/space.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/modsym/space.py	2018-10-17 14:33:46.446858262 -0600
@@ -432,7 +432,7 @@ class ModularSymbolsSpace(hecke.HeckeMod
         raise NotImplementedError("computation of cuspidal subspace not yet implemented for this class")
 
     def is_simple(self):
-        """
+        r"""
         Return whether not this modular symbols space is simple as a module
         over the anemic Hecke algebra adjoin \*.
 
@@ -1017,7 +1017,7 @@ class ModularSymbolsSpace(hecke.HeckeMod
         return V.span(sum(B, []))
 
     def _q_expansion_module_rational(self, prec):
-        """
+        r"""
         Return a vector space over `\QQ` for the space spanned by the
         `q`-expansions corresponding to self. The base ring of self must be
         `\QQ` or a number field, and self must be cuspidal. The returned space
@@ -1292,7 +1292,7 @@ class ModularSymbolsSpace(hecke.HeckeMod
     #########################################################################
 
     def q_expansion_cuspforms(self, prec=None):
-        """
+        r"""
         Returns a function f(i,j) such that each value f(i,j) is the
         q-expansion, to the given precision, of an element of the
         corresponding space `S` of cusp forms. Together these
@@ -1428,7 +1428,7 @@ class ModularSymbolsSpace(hecke.HeckeMod
         return self.modular_symbols_of_level(Integer(level))
 
     def sign(self):
-        """
+        r"""
         Returns the sign of self.
 
         For efficiency reasons, it is often useful to compute in the
--- src/sage/modular/pollack_stevens/distributions.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modular/pollack_stevens/distributions.py	2018-10-17 14:34:10.686545615 -0600
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-"""
+r"""
 Spaces of Distributions for Pollack-Stevens modular symbols
 
 The Pollack-Stevens version of modular symbols take values on a
--- src/sage/modules/filtered_vector_space.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/filtered_vector_space.py	2018-10-16 14:48:12.593862282 -0600
@@ -145,7 +145,7 @@ def is_FilteredVectorSpace(X):
 
 
 def FilteredVectorSpace(arg1, arg2=None, base_ring=QQ, check=True):
-    """
+    r"""
     Construct a filtered vector space.
 
     INPUT:
@@ -543,7 +543,7 @@ class FilteredVectorSpace_class(FreeModu
         return (len(f) == 1) or (len(f) == 2 and f[1][0] == infinity)
 
     def is_exhaustive(self):
-        """
+        r"""
         Return whether the filtration is exhaustive.
 
         A filtration $\{F_d\}$ in an ambient vector space $V$ is
@@ -568,7 +568,7 @@ class FilteredVectorSpace_class(FreeModu
             self.ambient_vector_space().dimension()
 
     def is_separating(self):
-        """
+        r"""
         Return whether the filtration is separating.
 
         A filtration $\{F_d\}$ in an ambient vector space $V$ is
--- src/sage/modules/free_module.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/free_module.py	2018-10-17 14:35:11.350763170 -0600
@@ -1037,7 +1037,7 @@ done from the right side.""")
         return self.element_class(self, x, coerce, copy)
 
     def __richcmp__(self, other, op):
-        """
+        r"""
         Rich comparison via containment in the same ambient space.
 
         Two modules compare if their ambient module/space is equal.
@@ -3361,7 +3361,7 @@ class FreeModule_generic_pid(FreeModule_
             True
 
         Next we try to create a submodule of a free module over the
-        principal ideal domain `\QQ[x]`, using our general Hermite normal form implementation::
+        principal ideal domain `\\QQ[x]`, using our general Hermite normal form implementation::
 
             sage: R = PolynomialRing(QQ, 'x'); x = R.gen()
             sage: M = FreeModule(R, 3)
@@ -4052,7 +4052,7 @@ class FreeModule_generic_field(FreeModul
         return self.submodule_with_basis(gens, check=check, already_echelonized=already_echelonized)
 
     def complement(self):
-        """
+        r"""
         Return the complement of ``self`` in the
         :meth:`~sage.modules.free_module.FreeModule_ambient_field.ambient_vector_space`.
 
--- src/sage/modules/free_quadratic_module.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/free_quadratic_module.py	2018-10-17 14:35:38.059418678 -0600
@@ -1186,7 +1186,7 @@ class FreeQuadraticModule_ambient_field(
 
 class FreeQuadraticModule_submodule_with_basis_pid(
     free_module.FreeModule_submodule_with_basis_pid, FreeQuadraticModule_generic_pid):
-    """
+    r"""
     An `R`-submodule of `K^n` with distinguished basis, where `K` is
     the fraction field of a principal ideal domain `R`.
 
--- src/sage/modules/matrix_morphism.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/matrix_morphism.py	2018-10-17 14:35:56.981174625 -0600
@@ -408,7 +408,7 @@ class MatrixMorphism_abstract(sage.categ
         return self.parent()(R(left) * self.matrix())
 
     def __mul__(self, right):
-        """
+        r"""
         Composition of morphisms, denoted by \*.
 
         EXAMPLES::
--- src/sage/modules/multi_filtered_vector_space.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/multi_filtered_vector_space.py	2018-10-16 14:48:45.473452907 -0600
@@ -236,7 +236,7 @@ class MultiFilteredVectorSpace_class(Fre
         return all(F.is_constant() for F in self._filt.values())
 
     def is_exhaustive(self):
-        """
+        r"""
         Return whether the multi-filtration is exhaustive.
 
         A filtration $\{F_d\}$ in an ambient vector space $V$ is
@@ -258,7 +258,7 @@ class MultiFilteredVectorSpace_class(Fre
         return all(F.is_exhaustive() for F in self._filt.values())
 
     def is_separating(self):
-        """
+        r"""
         Return whether the multi-filtration is separating.
 
         A filtration $\{F_d\}$ in an ambient vector space $V$ is
--- src/sage/modules/tensor_operations.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/tensor_operations.py	2018-10-16 14:49:04.432216861 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 Helper Classes to implement Tensor Operations
 
 .. warning::
--- src/sage/modules/torsion_quadratic_module.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/torsion_quadratic_module.py	2018-10-16 14:46:54.122839300 -0600
@@ -415,7 +415,7 @@ class TorsionQuadraticModule(FGP_Module_
         """
         if self._modulus_qf != 2:
             raise ValueError("The torsion quadratic form must have values in"
-                            "\QQ / 2\ZZ")
+                            "\\QQ / 2\\ZZ")
         from sage.quadratic_forms.genera.normal_form import collect_small_blocks
         brown = IntegerModRing(8).zero()
         for p in self.annihilator().gen().prime_divisors():
--- src/sage/modules/vector_callable_symbolic_dense.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/vector_callable_symbolic_dense.py	2018-10-16 14:36:42.833450284 -0600
@@ -78,7 +78,7 @@ class Vector_callable_symbolic_dense(fre
             return "(%s) |--> %s" % (args, repr_x)
 
     def _latex_(self):
-        """
+        r"""
         Returns the latex representation of the vector
 
         EXAMPLES::
--- src/sage/modules/with_basis/cell_module.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/with_basis/cell_module.py	2018-10-16 14:47:27.833419583 -0600
@@ -264,7 +264,7 @@ class CellModule(CombinatorialFreeModule
         return tuple([self.from_vector(v) for v in mat.left_kernel().basis()])
 
     def radical(self):
-        """
+        r"""
         Return the radical of ``self``.
 
         Let `W(\lambda)` denote a cell module. The *radical* of `W(\lambda)`
@@ -376,7 +376,7 @@ class CellModule(CombinatorialFreeModule
         _rmul_ = _acted_upon_
 
 class SimpleModule(QuotientModuleWithBasis):
-    """
+    r"""
     A simple module of a cellular algebra.
 
     Let `W(\lambda)` denote a cell module. The simple module `L(\lambda)`
--- src/sage/modules/with_basis/morphism.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/modules/with_basis/morphism.py	2018-10-17 14:36:44.996555318 -0600
@@ -879,7 +879,7 @@ class TriangularModuleMorphism(ModuleMor
         return self.preimage( self.codomain().monomial(i) )
 
     def preimage(self, f):
-        """
+        r"""
         Return the preimage of `f` under ``self``.
 
         EXAMPLES::
@@ -978,7 +978,7 @@ class TriangularModuleMorphism(ModuleMor
         return out
 
     def coreduced(self, y):
-        """
+        r"""
         Return `y` reduced w.r.t. the image of ``self``.
 
         INPUT:
@@ -1069,7 +1069,7 @@ class TriangularModuleMorphism(ModuleMor
     co_reduced = deprecated_function_alias(8678, coreduced)
 
     def cokernel_basis_indices(self):
-        """
+        r"""
         Return the indices of the natural monomial basis of the cokernel of ``self``.
 
         INPUT:
@@ -1496,7 +1496,7 @@ class DiagonalModuleMorphism(ModuleMorph
         return self.codomain().term(i, self._diagonal(i))
 
     def __invert__(self):
-        """
+        r"""
         Return the inverse diagonal morphism.
 
         EXAMPLES::
--- src/sage/monoids/free_abelian_monoid.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/monoids/free_abelian_monoid.py	2018-10-17 14:37:19.699107721 -0600
@@ -112,7 +112,7 @@ FreeAbelianMonoid_factory = FreeAbelianM
 
 @rename_keyword(deprecation=15289, n="index_set")
 def FreeAbelianMonoid(index_set=None, names=None, **kwds):
-    """
+    r"""
     Return a free abelian monoid on `n` generators or with the generators
     indexed by a set `I`.
 
--- src/sage/monoids/free_monoid_element.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/monoids/free_monoid_element.py	2018-10-17 14:37:43.610799309 -0600
@@ -358,7 +358,7 @@ class FreeMonoidElement(MonoidElement):
         return W(sum([ [alph[gens.index(i[0])]] * i[1] for i in list(self) ], []))
 
     def to_list(self, indices=False):
-        """
+        r"""
         Return ``self`` as a list of generators.
 
         If ``self`` equals `x_{i_1} x_{i_2} \cdots x_{i_n}`, with
--- src/sage/numerical/optimize.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/numerical/optimize.py	2018-10-16 14:32:41.588454112 -0600
@@ -19,7 +19,7 @@ from sage.misc.decorators import rename_
 
 
 def find_root(f, a, b, xtol=10e-13, rtol=2.0**-50, maxiter=100, full_output=False):
-    """
+    r"""
     Numerically find a root of ``f`` on the closed interval `[a,b]`
     (or `[b,a]`) if possible, where ``f`` is a function in the one variable.
     Note: this function only works in fixed (machine) precision, it is not
@@ -493,7 +493,7 @@ def minimize_constrained(func,cons,x0,gr
 
 
 def linear_program(c,G,h,A=None,b=None,solver=None):
-    """
+    r"""
     Solves the dual linear programs:
 
     - Minimize  `c'x` subject to `Gx + s = h`, `Ax = b`, and `s \geq 0` where
--- src/sage/rings/number_field/number_field_rel.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/rings/number_field/number_field_rel.py	2018-10-17 14:41:49.841623412 -0600
@@ -1387,7 +1387,7 @@ class NumberField_relative(NumberField_g
         return self.__relative_vector_space
 
     def absolute_vector_space(self):
-        """
+        r"""
         Return vector space over `\QQ` of self and isomorphisms from
         the vector space to self and in the other direction.
 
--- src/sage/rings/padics/padic_base_generic.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/rings/padics/padic_base_generic.py	2018-10-17 14:42:19.824236696 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 `p`-Adic Base Generic
 
 A superclass for implementations of `\mathbb{Z}_p` and `\mathbb{Q}_p`.
--- src/sage/rings/padics/padic_base_leaves.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/rings/padics/padic_base_leaves.py	2018-10-17 14:42:47.758876387 -0600
@@ -1,4 +1,4 @@
-"""
+r"""
 `p`-Adic Base Leaves
 
 Implementations of `\mathbb{Z}_p` and `\mathbb{Q}_p`
--- src/sage/rings/padics/padic_generic.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/rings/padics/padic_generic.py	2018-10-17 14:43:10.376584662 -0600
@@ -997,7 +997,7 @@ class pAdicGeneric(PrincipalIdealDomain,
 
     @cached_method
     def _log_unit_part_p(self):
-        """
+        r"""
         Compute the logarithm of the unit-part of `p`.
 
         If `\pi` is the uniformizer in this ring, then we can uniquely write
--- src/sage/rings/padics/unramified_extension_generic.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/rings/padics/unramified_extension_generic.py	2018-10-17 14:43:32.246302588 -0600
@@ -332,7 +332,7 @@ class UnramifiedExtensionGeneric(pAdicEx
         return self.ground_ring().has_pth_root()
 
     def has_root_of_unity(self, n):
-        """
+        r"""
         Returns whether or not `\ZZ_p` has a primitive `n^{\mbox{th}}`
         root of unity.
 
--- src/sage_setup/docbuild/sphinxbuild.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage_setup/docbuild/sphinxbuild.py	2018-10-16 13:59:50.609965820 -0600
@@ -69,9 +69,9 @@ class SageSphinxLogger(object):
             re.compile('^Compiling a sub-document'),
             re.compile('^updating environment: 0 added, 0 changed, 0 removed'),
             re.compile('^looking for now-outdated files... none found'),
-            re.compile('^building \[.*\]: targets for 0 source files that are out of date'),
+            re.compile('^building \\[.*\\]: targets for 0 source files that are out of date'),
             re.compile('^loading pickled environment... done'),
-            re.compile('^loading cross citations... done \([0-9]* citations\).'),
+            re.compile('^loading cross citations... done \\([0-9]* citations\\).'),
             re.compile('WARNING: favicon file \'favicon.ico\' does not exist'),
             re.compile('WARNING: html_static_path entry .* does not exist'),
             re.compile('WARNING: while setting up extension'),
--- build/pkgs/sagenb/src/sagenb/flask_version/worksheet_listing.py.orig	2018-01-24 04:17:47.000000000 -0700
+++ build/pkgs/sagenb/src/sagenb/flask_version/worksheet_listing.py	2018-10-17 09:36:47.843468652 -0600
@@ -2,7 +2,14 @@
 """
 from __future__ import absolute_import
 import os
-import urllib, urlparse
+
+try:
+    from urllib.request import urlopen
+    from urllib.parse import urlparse
+except ImportError:
+    from urlparse import urlparse
+    from urllib import urlopen
+
 from flask import Blueprint, url_for, render_template, request, session, redirect, g, current_app
 from .decorators import login_required, guest_or_login_required, with_lock
 from flask_babel import Babel, gettext, ngettext, lazy_gettext
--- build/pkgs/sagenb/src/sagenb/misc/misc.py.orig	2018-08-29 08:44:38.823169061 -0600
+++ build/pkgs/sagenb/src/sagenb/misc/misc.py	2018-10-17 09:39:14.346569538 -0600
@@ -19,6 +19,7 @@ Check that github issue #195 is fixed::
 #                  http://www.gnu.org/licenses/
 #############################################################################
 
+from six import text_type, binary_type
 from pkg_resources import resource_filename
 
 def stub(f):
@@ -416,6 +417,8 @@ def encoded_str(obj, encoding='utf-8'):
     r"""
     Takes an object and returns an encoded str human-readable representation.
 
+    string to bytes
+
     EXAMPLES::
 
         sage: from sagenb.misc.misc import encoded_str
@@ -426,14 +429,16 @@ def encoded_str(obj, encoding='utf-8'):
         sage: encoded_str(123)
         '123'
     """
-    if isinstance(obj, unicode):
+    if isinstance(obj, text_type):
         return obj.encode(encoding, 'ignore')
-    return str(obj)
+    return binary_type(obj)
 
 def unicode_str(obj, encoding='utf-8'):
     r"""
     Takes an object and returns a unicode human-readable representation.
 
+    (bytes or string) to string
+
     EXAMPLES::
 
         sage: from sagenb.misc.misc import unicode_str
@@ -444,11 +449,11 @@ def unicode_str(obj, encoding='utf-8'):
         sage: unicode_str(123)
         u'123'
     """
-    if isinstance(obj, str):
+    if isinstance(obj, binary_type):
         return obj.decode(encoding, 'ignore')
-    elif isinstance(obj, unicode):
+    elif isinstance(obj, text_type):
         return obj
-    return unicode(obj)
+    return text_type(obj)
         
 
 
--- build/pkgs/sagenb/src/sagenb/misc/sphinxify.py.orig	2018-06-10 13:56:16.000000000 -0600
+++ build/pkgs/sagenb/src/sagenb/misc/sphinxify.py	2018-10-17 09:42:45.846827860 -0600
@@ -19,6 +19,7 @@ AUTHORS:
 import os
 import re
 import shutil
+import six.moves
 from tempfile import mkdtemp
 
 # We import Sphinx on demand, to reduce Sage startup time.
@@ -94,9 +95,8 @@ def sphinxify(docstring, format='html'):
         suffix = '.txt'
     output_name = base_name + suffix
 
-    filed = open(rst_name, 'w')
-    filed.write(docstring)
-    filed.close()
+    with open(rst_name, 'w') as filed:
+        filed.write(docstring)
 
     # Sphinx constructor: Sphinx(srcdir, confdir, outdir, doctreedir,
     # buildername, confoverrides, status, warning, freshenv).
@@ -119,9 +119,9 @@ def sphinxify(docstring, format='html'):
     sphinx_app.build(None, [rst_name])
     sys.path = old_sys_path
 
-    #We need to remove "_" from __builtin__ that the gettext module installs
-    import __builtin__
-    __builtin__.__dict__.pop('_', None)
+    # We need to remove "_" from __builtin__ that the gettext module installs
+    from six.moves import builtins
+    builtins.__dict__.pop('_', None)
 
     if os.path.exists(output_name):
         output = open(output_name, 'r').read()
@@ -134,8 +134,8 @@ def sphinxify(docstring, format='html'):
         # to
         #    "/doc/static/reference/media/...path.../blah.png"
         output = re.sub("""src=['"](/?\.\.)*/?media/([^"']*)['"]""",
-                          'src="/doc/static/reference/media/\\2"',
-                          output)
+                        'src="/doc/static/reference/media/\\2"',
+                        output)
         # Remove spurious \(, \), \[, \].
         output = output.replace('\\(', '').replace('\\)', '').replace('\\[', '').replace('\\]', '')
     else:
@@ -481,7 +481,7 @@ skip_picklability_check_modules = [
     #'sage.misc.nested_class_test', # for test only
     'sage.misc.latex',
     'sage.misc.explain_pickle',
-    '__builtin__',
+    'builtins',
 ]
 
 def check_nested_class_picklability(app, what, name, obj, skip, options):
@@ -532,7 +532,7 @@ def skip_member(app, what, name, obj, sk
     if 'SAGE_CHECK_NESTED' in os.environ:
         check_nested_class_picklability(app, what, name, obj, skip, options)
 
-    if getattr(obj, '__module__', None) == '__builtin__':
+    if getattr(obj, '__module__', None) == 'builtins':
         return True
 
     if (hasattr(obj, '__name__') and obj.__name__.find('.') != -1 and
--- build/pkgs/sagenb/src/sagenb/misc/support.py.orig	2018-05-22 10:01:48.000000000 -0600
+++ build/pkgs/sagenb/src/sagenb/misc/support.py	2018-10-17 09:23:38.909683823 -0600
@@ -17,7 +17,7 @@ import sys
 import pydoc
 
 from six import iteritems
-import __builtin__
+import builtins
 
 try:
     from cPickle import PicklingError
@@ -467,7 +467,7 @@ def cython_import(filename, verbose=Fals
                                             use_cache=use_cache,
                                             create_local_c_file=create_local_c_file)
     sys.path.append(build_dir)
-    return __builtin__.__import__(name)
+    return builtins.__import__(name)
 
 
 def cython_import_all(filename, globals, verbose=False, compile_message=False,
--- build/pkgs/sagenb/src/sagenb/notebook/cell.py.orig	2018-08-29 08:44:38.823169061 -0600
+++ build/pkgs/sagenb/src/sagenb/notebook/cell.py	2018-10-17 09:40:11.817824538 -0600
@@ -20,6 +20,7 @@ import shutil
 import textwrap
 import time
 from cgi import escape
+from sys import maxsize
 
 from sagenb.misc.misc import (word_wrap, strip_string_literals,
                               set_restrictive_permissions, unicode_str,
@@ -701,9 +702,8 @@ class Cell(Cell_generic):
 
         # start with a random integer so that evaluations of the cell
         # from different runs have different version numbers.
-        from sys import maxint
         from random import randint
-        self._version = randint(0,maxint)
+        self._version = randint(0, maxsize)
 
     def __repr__(self):
         """
@@ -2189,9 +2189,8 @@ class Cell(Cell_generic):
         except AttributeError:
             # start with a random integer so that evaluations of the cell
             # from different runs have different version numbers.
-            from sys import maxint
             from random import randint
-            self._version = randint(0,maxint)
+            self._version = randint(0, maxsize)
             return self._version
 
     def time(self):
--- build/pkgs/sagenb/src/sagenb/notebook/docHTMLProcessor.py.orig	2018-01-24 04:17:38.000000000 -0700
+++ build/pkgs/sagenb/src/sagenb/notebook/docHTMLProcessor.py	2018-10-17 09:51:50.480773614 -0600
@@ -7,7 +7,7 @@ file.
 
 This takes an HTML document, i.e., Sage documentation, and returns it in
 the editable format (notebook worksheet format with evaluable examples). It
-also returns a string representing the CSS link for the document.  The SGML
+also returns a string representing the CSS link for the document.  The HTML
 parser is setup to return only the body of the HTML documentation page and
 to re-format Sage examples and type-setting.
 
@@ -25,7 +25,7 @@ This module contains three classes:
 
 .. NOTE:: 
 
-    This extension of sgmllib.SGMLParser was partly inspired by Mark
+    This extension of sgmllib.HTMLParser was partly inspired by Mark
     Pilgrim's 'Dive Into Python' examples.
 
 AUTHORS:
@@ -111,14 +111,14 @@ WARNING:
 #############################################################################
 from __future__ import unicode_literals
 
-from sgmllib import SGMLParser
+from html.parser import HTMLParser
 from htmlentitydefs import entitydefs
 
 from flask import Markup
 from sagenb.misc.misc import unicode_str
 
 
-class genericHTMLProcessor(SGMLParser):
+class genericHTMLProcessor(HTMLParser):
     r"""
     This class gathers the methods that are common to both classes
     :class:`sagenb.notebook.SphinxHTMLProcessor` and
@@ -155,16 +155,16 @@ class genericHTMLProcessor(SGMLParser):
             u'<h1 class="title">Title</h1>\n\n<p>nSome text</p>\n\n\n\n'
 
         """        
-        # self.feed() is a SGMLParser method and starts everything
+        # self.feed() is a HTMLParser method and starts everything
         # off; Most of the functions here are extensions to
-        # SGMLParser, and may never actually be visibly called here.
+        # HTMLParser, and may never actually be visibly called here.
 
         # This module works with unicode literals. In case that input data is
         # ascii, exceptions may occur. So, input data must be converted to
         # unicode if it were not.
         doc_in = unicode_str(doc_in)  
-        self.feed(doc_in) #SGMLParser call
-        self.close()     #SGMLParser call
+        self.feed(doc_in) #HTMLParser call
+        self.close()     #HTMLParser call
         self.hand_off_temp_pieces('to_doc_pieces')
         return self.all_pieces.replace('\\(', '').replace('\\)', '').replace('\\[', '').replace('\\]', '')
 
@@ -390,7 +390,7 @@ class genericHTMLProcessor(SGMLParser):
                 else:
                     # first occurrence of an output string
                     # write /// denoting output
-                    if output_flag == False:
+                    if output_flag is False:
                         piece += '///'
                         if p:
                             piece += '\n' + p
@@ -400,7 +400,29 @@ class genericHTMLProcessor(SGMLParser):
                         piece += p
             piece += '\n}}}\n\n'
         return Markup(piece).unescape()
-                
+
+    def handle_starttag(self, tag, attrs):
+        """
+        introduced when replacing SGMLParser by HTMLParser
+        """
+        try:
+            method = getattr(self, 'start_' + tag)
+        except AttributeError:
+            self.unknown_starttag(tag, attrs)
+        else:
+            method(attrs)
+
+    def handle_endtag(self, tag):
+        """
+        introduced when replacing SGMLParser by HTMLParser
+        """
+        try:
+            method = getattr(self, 'end_' + tag)
+        except AttributeError:
+            self.unknown_endtag(tag)
+        else:
+            method()
+ 
     ##############################################
     ## General tag handlers
     ## These just append their HTML to self.temp_pieces.
@@ -473,6 +495,7 @@ class genericHTMLProcessor(SGMLParser):
         """
         if self.keep_data:
             self.temp_pieces.append(data)
+
     def handle_charref(self, ref):
         r"""
         INPUT:
@@ -540,6 +563,7 @@ class genericHTMLProcessor(SGMLParser):
         """
         if self.keep_data:
             self.temp_pieces.append("<!--%(data)s-->" % locals())
+
     def handle_pi(self, text):
         r"""
         Handle processing instructions
@@ -585,7 +609,7 @@ class genericHTMLProcessor(SGMLParser):
         """
         if self.keep_data:
             self.temp_pieces.append("<!%(text)s>" % locals())
-        
+
     ##############################################
     ## Specific tag handlers
     def start_body(self, attrs):
@@ -634,6 +658,7 @@ class genericHTMLProcessor(SGMLParser):
             ['bunch ', 'of ', 'tmp ', 'strings'] 
         """
         pass
+
     def end_html(self):
         r"""
         INPUT:
@@ -658,7 +683,7 @@ class SphinxHTMLProcessor(genericHTMLPro
     def reset(self):
         r"""
         Initialize necessary variables.  Called by
-        :meth:`SGMLParser.__init__`.
+        :meth:`HTMLParser.__init__`.
 
         EXAMPLES::
 
@@ -685,8 +710,8 @@ class SphinxHTMLProcessor(genericHTMLPro
 
         # counters
         self.cellcount = 0
-                
-        SGMLParser.reset(self)
+
+        HTMLParser.reset(self)
 
     def false_positive_input_output_cell(self, cell_piece):
         r"""
@@ -733,7 +758,7 @@ class SphinxHTMLProcessor(genericHTMLPro
         Once we hit the <div> tag in a highlighted block,
         hand of all of the pieces we've encountered so far
         and ignore the tag.
-        
+
         INPUT:
 
         - ``attrs`` - list of tuple
@@ -835,7 +860,7 @@ class SphinxHTMLProcessor(genericHTMLPro
             self.hand_off_temp_pieces('to_cell_pieces')
             return
         self.temp_pieces.append("</div>")
-    
+
     def start_pre(self, attrs):
         r"""
         Ignore tag <pre> when inside highligh div.
@@ -1000,6 +1025,7 @@ class SphinxHTMLProcessor(genericHTMLPro
         if self.in_highlight_div:
             return
         self.unknown_starttag('span', attrs)
+
     def end_span(self):
         r"""
         Ignore all spans that occur within highlighted blocks
@@ -1095,7 +1121,7 @@ class docutilsHTMLProcessor(genericHTMLP
     def reset(self):
         r"""
         Initialize necessary variables.  Called by
-        :meth:`SGMLParser.__init__`.
+        :meth:`HTMLParser.__init__`.
 
         EXAMPLES::
 
@@ -1125,8 +1151,8 @@ class docutilsHTMLProcessor(genericHTMLP
 
         # counters
         self.cellcount = 0
-                
-        SGMLParser.reset(self)
+
+        HTMLParser.reset(self)
 
     def false_positive_input_output_cell(self, cell_piece):
         r"""
@@ -1162,7 +1188,7 @@ class docutilsHTMLProcessor(genericHTMLP
         piece = piece.replace('}','}&nbsp;')
         piece += '\n</pre>'
         return piece
-    
+
     #############################################
     ## Specific tag handlers
     ##
--- build/pkgs/sagenb/src/sagenb/notebook/notebook.py.orig	2018-05-22 10:16:28.000000000 -0600
+++ build/pkgs/sagenb/src/sagenb/notebook/notebook.py	2018-10-17 09:41:05.937122985 -0600
@@ -1268,7 +1268,7 @@ class Notebook(object):
             W.set_not_computing()
 
     def quit(self):
-        for W in self.__worksheets.values():
+        for W in list(self.__worksheets.values()):
             W.quit()
 
     def update_worksheet_processes(self):
--- build/pkgs/sagetex/src/extractsagecode.py.orig	2015-08-26 17:28:42.000000000 -0600
+++ build/pkgs/sagetex/src/extractsagecode.py	2018-10-16 15:51:25.115052207 -0600
@@ -45,8 +45,8 @@ See the SageTeX documentation for more d
 
 try:
   opts, args = getopt.getopt(sys.argv[1:], 'ho', ['help', 'overwrite'])
-except getopt.GetoptError, err:
-  print str(err)
+except getopt.GetoptError as err:
+  print(str(err))
   usage()
   sys.exit(2)
 
--- build/pkgs/sagetex/src/makestatic.py.orig	2015-08-26 17:28:42.000000000 -0600
+++ build/pkgs/sagetex/src/makestatic.py	2018-10-16 15:52:13.282441276 -0600
@@ -45,8 +45,8 @@ See the SageTeX documentation for more d
 
 try:
   opts, args = getopt.getopt(sys.argv[1:], 'ho', ['help', 'overwrite'])
-except getopt.GetoptError, err:
-  print str(err)
+except getopt.GetoptError as err:
+  print(str(err))
   usage()
   sys.exit(2)
 
--- build/pkgs/sagetex/src/remote-sagetex.py.orig	2015-08-26 17:28:42.000000000 -0600
+++ build/pkgs/sagetex/src/remote-sagetex.py	2018-10-16 15:53:14.073670222 -0600
@@ -24,12 +24,11 @@
 ## You should have received a copy of the GNU General Public License along
 ## with this program.  If not, see <http://www.gnu.org/licenses/>.
 ## 
-from __future__ import print_function
 import json
 import sys
 import time
 import re
-import urllib
+import urllib.request, urllib.parse, urllib.error
 import hashlib
 import os
 import os.path
@@ -156,7 +155,7 @@ class RemoteSage:
                                    '\n*(?P<output>.*)', re.DOTALL)
         self._404 = re.compile('404 Not Found')
         self._session = self._get_url('login',
-                                    urllib.urlencode({'username': user,
+                                    urllib.parse.urlencode({'username': user,
                                     'password':
                                     password}))['session']
         self._codewrap = """try:
@@ -176,10 +175,10 @@ except:
             _p_.save(filename=plotfilename, **kwargs)""")
 
     def _encode(self, d):
-        return 'session={0}&'.format(self._session) + urllib.urlencode(d)
+        return 'session={0}&'.format(self._session) + urllib.parse.urlencode(d)
 
     def _get_url(self, action, u):
-        with closing(urllib.urlopen(self._srv + '/simple/' + action +
+        with closing(urllib.request.urlopen(self._srv + '/simple/' + action +
                                     '?' + u)) as h:
             data = self._response.match(h.read())
             result = json.loads(data.group('header'))
@@ -187,7 +186,7 @@ except:
         return result
 
     def _get_file(self, fn, cell, ofn=None):
-        with closing(urllib.urlopen(self._srv + '/simple/' + 'file' + '?' +
+        with closing(urllib.request.urlopen(self._srv + '/simple/' + 'file' + '?' +
                      self._encode({'cell': cell, 'file': fn}))) as h:
             myfn = ofn if ofn else fn
             data = h.read()
@@ -277,13 +276,13 @@ if login_info_file:
                     password = get_val(line)
 
 if not server:
-    server = raw_input('Enter server: ')
+    server = input('Enter server: ')
 
 if not server.startswith('http'):
     server = 'https://' + server
 
 if not username:
-    username = raw_input('Enter username: ')
+    username = input('Enter username: ')
 
 if not password:
     from getpass import getpass
--- build/pkgs/sagetex/src/run-sagetex-if-necessary.py.orig	2015-08-26 17:28:42.000000000 -0600
+++ build/pkgs/sagetex/src/run-sagetex-if-necessary.py	2018-10-16 15:53:46.501258922 -0600
@@ -58,7 +58,7 @@ with open(src + '.tex') as texf:
             break
 
 if not uses_sagetex:
-    print src + ".tex doesn't seem to use SageTeX, exiting."
+    print(src + ".tex doesn't seem to use SageTeX, exiting.")
     sys.exit(0)
 
 # if something goes wrong, assume we need to run Sage
@@ -72,7 +72,7 @@ try:
             if not re.search(ignore, line):
                 h.update(line)
 except IOError:
-    print '{0}.sagetex.sage not found, I think you need to typeset {0}.tex first.'.format(src)
+    print('{0}.sagetex.sage not found, I think you need to typeset {0}.tex first.'.format(src))
     sys.exit(1)
 
 try:
@@ -80,8 +80,8 @@ try:
         for line in outf:
             m = re.match('%([0-9a-f]+)% md5sum', line)
             if m:
-                print 'computed md5:', h.hexdigest()
-                print 'sagetex.sout md5:', m.group(1)
+                print('computed md5:', h.hexdigest())
+                print('sagetex.sout md5:', m.group(1))
                 if h.hexdigest() == m.group(1):
                     run_sage = False
                     break
@@ -89,7 +89,7 @@ except IOError:
     pass
 
 if run_sage:
-    print 'Need to run Sage on {0}.'.format(src)
+    print('Need to run Sage on {0}.'.format(src))
     sys.exit(subprocess.call([path_to_sage, src + '.sagetex.sage']))
 else:
-    print 'Not necessary to run Sage on {0}.'.format(src)
+    print('Not necessary to run Sage on {0}.'.format(src))
--- build/pkgs/sagetex/src/sagetexparse.py.orig	2015-08-26 17:28:42.000000000 -0600
+++ build/pkgs/sagetex/src/sagetexparse.py	2018-10-16 15:54:08.097984998 -0600
@@ -52,7 +52,7 @@ class SoutParser():
     try:
       OneOrMore(parselabel).parseFile(fn)
     except IOError:
-      print 'Error accessing %s; exiting. Does your .sout file exist?' % fn
+      print('Error accessing %s; exiting. Does your .sout file exist?' % fn)
       sys.exit(1)
   def newlabel(self, s, l, t):
     self.label.append(t.result[1:-1])
--- build/pkgs/sagetex/src/sagetex.py.orig	2015-08-26 17:28:42.000000000 -0600
+++ build/pkgs/sagetex/src/sagetex.py	2018-10-16 15:54:27.882734058 -0600
@@ -73,10 +73,10 @@ from your current version of Sage; see
 http://www.sagemath.org/doc/installation/sagetex.html.""".format(jobname,
   version, pyversion)
       if version_check:
-        raise VersionError, errstr
+        raise VersionError(errstr)
       else:
-        print '**** WARNING! Skipping version check for .sty and .py files, and'
-        print errstr
+        print('**** WARNING! Skipping version check for .sty and .py files, and')
+        print(errstr)
     if ' ' in jobname:
       jobname = jobname.strip('"')
     self.progress('Processing Sage code for {0}.tex...'.format(jobname))
@@ -116,7 +116,7 @@ http://www.sagemath.org/doc/installation
       elif labelname == 'sagecmdline':
           pass # output message already printed
       else:
-          raise ValueError, 'inline() got a bad labelname "{0}"'.format(labelname)
+          raise ValueError('inline() got a bad labelname "{0}"'.format(labelname))
       self.souttmp.write(r'\newlabel{@' + labelname + str(counter) +
                          '}{{%\n' + s.rstrip() + '}{}{}{}{}}\n')
   def savecmd(self, s):
@@ -178,7 +178,7 @@ http://www.sagemath.org/doc/installation
                            latex(result),
                            r' \end{displaymath}']
           except SyntaxError:
-              exec preparse(splitup[i][2]) in globals, locals
+              exec(preparse(splitup[i][2]), globals, locals)
       self.inline(counter, '\n'.join(tex_strs))
   def commandline(self, counter, s, globals, locals, text_output):
       self.progress('Sage commandline {0} (line {1})'.format(counter, self.current_tex_line))
@@ -208,7 +208,7 @@ http://www.sagemath.org/doc/installation
                                   latex(result) +
                                   r'\end{displaymath}')
           except SyntaxError:
-              exec preparse(splitup[i][2]) in globals, locals
+              exec(preparse(splitup[i][2]), globals, locals)
       if 'displaymath' not in tex_strs[-1]:
           tex_strs.append(skip)
       self.inline(counter, '\n'.join(tex_strs), labelname='sagecmdline')
@@ -233,8 +233,8 @@ http://www.sagemath.org/doc/installation
           except ValueError as inst:
               if re.match('filetype .*not supported by save', str(inst)):
                   newfilename = plotfilename[:-3] + 'png'
-                  print '  saving {0} failed; saving to {1} instead.'.format(
-                                                    plotfilename, newfilename)
+                  print('  saving {0} failed; saving to {1} instead.'.format(
+                                                    plotfilename, newfilename))
                   _p_.save(filename=newfilename, **kwargs)
                   break
               else:
@@ -248,11 +248,11 @@ http://www.sagemath.org/doc/installation
       '{0}/plot-{1}.{2}'.format(self.plotdir, counter, ext), \
       '{0}/plot-{1}.eps'.format(self.plotdir, counter)])
   def goboom(self, line):
-    print('\n**** Error in Sage code on line {0} of {1}.tex! Traceback\
- follows.'.format(line, self.filename))
+    print(('\n**** Error in Sage code on line {0} of {1}.tex! Traceback\
+ follows.'.format(line, self.filename)))
     traceback.print_exc()
-    print('\n**** Running Sage on {0}.sage failed! Fix {0}.tex and try\
- again.'.format(self.filename))
+    print(('\n**** Running Sage on {0}.sage failed! Fix {0}.tex and try\
+ again.'.format(self.filename)))
     self.souttmp.close()
     os.remove(self.filename + '.sagetex.sout.tmp')
     self.scmdtmp.close()
--- src/doc/common/conf.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/doc/common/conf.py	2018-10-17 09:25:21.876352155 -0600
@@ -504,7 +504,7 @@ skip_picklability_check_modules = [
     #'sage.misc.nested_class_test', # for test only
     'sage.misc.latex',
     'sage.misc.explain_pickle',
-    '__builtin__',
+    'builtins',
 ]
 
 def check_nested_class_picklability(app, what, name, obj, skip, options):
@@ -553,7 +553,7 @@ def skip_member(app, what, name, obj, sk
     if 'SAGE_CHECK_NESTED' in os.environ:
         check_nested_class_picklability(app, what, name, obj, skip, options)
 
-    if getattr(obj, '__module__', None) == '__builtin__':
+    if getattr(obj, '__module__', None) == 'builtins':
         return True
 
     objname = getattr(obj, "__name__", None)
--- src/sage/arith/long.pxd.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/arith/long.pxd	2018-10-16 11:34:30.788518682 -0600
@@ -19,7 +19,7 @@ from cpython.object cimport Py_SIZE
 from cpython.int cimport PyInt_AS_LONG
 from cpython.long cimport PyLong_AsLong
 from cpython.number cimport PyNumber_Index, PyIndex_Check
-from cpython.longintrepr cimport PyLongObject, PyLong_SHIFT, digit
+from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
 
 from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
 from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
@@ -208,7 +208,7 @@ cdef inline bint integer_check_long_py(x
         return 0
 
     # x is a Python "long" (called "int" on Python 3)
-    cdef const digit* D = (<PyLongObject*>x).ob_digit
+    cdef const digit* D = (<py_long>x).ob_digit
     cdef Py_ssize_t size = Py_SIZE(x)
 
     # We assume that PyLong_SHIFT is 15 on a 32-bit system and 30 on a
--- src/sage/combinat/finite_state_machine.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/combinat/finite_state_machine.py	2018-10-17 08:18:20.455010671 -0600
@@ -938,6 +938,7 @@ from six import itervalues
 from six.moves import zip_longest
 
 import collections
+import collections.abc
 import itertools
 
 import sage
@@ -14143,7 +14144,7 @@ def is_FSMProcessIterator(PI):
 
 
 class FSMProcessIterator(sage.structure.sage_object.SageObject,
-                         collections.Iterator):
+                         collections.abc.Iterator):
     """
     This class takes an input, feeds it into a finite state machine
     (automaton or transducer, in particular), tests whether this was
--- src/sage/cpython/dict_del_by_value.pyx.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/cpython/dict_del_by_value.pyx	2018-10-14 20:42:23.000000000 -0600
@@ -347,8 +347,8 @@ ELIF PY_VERSION_HEX>=0x03060000:
         cdef MyPyDictKeysObject * keys = <MyPyDictKeysObject *>(mp.ma_keys)
         cdef size_t perturb
         cdef size_t mask = <size_t> keys.dk_size-1
-        cdef PyDictKeyEntry *entries, *ep
-        entries = DK_ENTRIES(keys)
+        cdef PyDictKeyEntry *ep
+        cdef PyDictKeyEntry *entries = DK_ENTRIES(keys)
 
         if mp.ma_values != NULL:
             print ("del_dictitem_by_exact_value cannot be applied to a shared key dict")
--- src/sage/geometry/polyhedron/backend_cdd.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/geometry/polyhedron/backend_cdd.py	2018-10-16 15:47:39.662235848 -0600
@@ -49,7 +49,7 @@ class Polyhedron_cdd(Polyhedron_base):
         """
         from .cdd_file_format import cdd_Vrepresentation
         s = cdd_Vrepresentation(self._cdd_type, vertices, rays, lines)
-        self._init_from_cdd_input(s, '--reps', verbose)
+        self._init_from_cdd_input(s, b'--reps', verbose)
 
 
     def _init_from_Hrepresentation(self, ieqs, eqns, verbose=False):
@@ -78,7 +78,7 @@ class Polyhedron_cdd(Polyhedron_base):
         """
         from .cdd_file_format import cdd_Hrepresentation
         s = cdd_Hrepresentation(self._cdd_type, ieqs, eqns)
-        self._init_from_cdd_input(s, '--reps', verbose)
+        self._init_from_cdd_input(s, b'--reps', verbose)
 
 
     def _init_facet_adjacency_matrix(self, verbose=False):
@@ -103,7 +103,7 @@ class Polyhedron_cdd(Polyhedron_base):
             [1 1 0]
         """
         self._init_from_cdd_input(self.cdd_Hrepresentation(),
-                                  '--adjacency', verbose)
+                                  b'--adjacency', verbose)
 
 
     def _init_vertex_adjacency_matrix(self, verbose=False):
@@ -128,7 +128,7 @@ class Polyhedron_cdd(Polyhedron_base):
             [1 1 0]
         """
         self._init_from_cdd_input(self.cdd_Vrepresentation(),
-                                  '--adjacency', verbose)
+                                  b'--adjacency', verbose)
 
 
     def _init_from_cdd_input(self, cdd_input_string, cmdline_arg='--all', verbose=False):
--- src/sage/graphs/generators/families.py.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/graphs/generators/families.py	2018-10-17 09:30:21.545476230 -0600
@@ -3144,7 +3144,7 @@ def MuzychukS6Graph(n, d, Phi='fixed', S
     from sage.rings.integer_ring import ZZ
     from time import time
     import itertools
-    from __builtin__ import range # we cannot use xrange here
+    from six.moves import range # we cannot use xrange here
 
     assert d > 1,              'd must be at least 2'
     assert is_even(n * (d-1)), 'n must be even or d must be odd'
--- src/sage/libs/gap/util.pyx.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/libs/gap/util.pyx	2018-10-16 15:27:53.043771756 -0600
@@ -171,7 +171,7 @@ def gap_root():
         return GAP_ROOT_DIR
     print('The gap-4.5.5.spkg (or later) seems to be not installed!')
     gap_sh = open(os.path.join(SAGE_LOCAL, 'bin', 'gap')).read().splitlines()
-    gapdir = filter(lambda dir:dir.strip().startswith('GAP_DIR'), gap_sh)[0]
+    gapdir = next(filter(lambda dir:dir.strip().startswith('GAP_DIR'), gap_sh))
     gapdir = gapdir.split('"')[1]
     gapdir = gapdir.replace('$SAGE_LOCAL', SAGE_LOCAL)
     return gapdir
--- src/sage/libs/gmp/pylong.pyx.orig	2018-08-03 05:10:08.000000000 -0600
+++ src/sage/libs/gmp/pylong.pyx	2018-10-16 11:45:44.610884365 -0600
@@ -28,7 +28,7 @@ AUTHORS:
 from cpython.object cimport Py_SIZE
 from cpython.int cimport PyInt_FromLong
 from cpython.long cimport PyLong_FromLong
-from cpython.longintrepr cimport _PyLong_New, PyLongObject, digit, PyLong_SHIFT
+from cpython.longintrepr cimport py_long, _PyLong_New, digit, PyLong_SHIFT
 from .mpz cimport *
 
 cdef extern from *:
@@ -54,7 +54,7 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
     cdef size_t nbits = mpz_sizeinbase(z, 2)
     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
     L = _PyLong_New(pylong_size)
-    mpz_export((<PyLongObject*>L).ob_digit, NULL,
+    mpz_export(L.ob_digit, NULL,
             -1, sizeof(digit), 0, PyLong_nails, z)
     if mpz_sgn(z) < 0:
         # Set correct size (use a pointer to hack around Cython's
@@ -91,7 +91,7 @@ cdef int mpz_set_pylong(mpz_ptr z, L) ex
     if pylong_size < 0:
         pylong_size = -pylong_size
     mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
-            (<PyLongObject*>L).ob_digit)
+            (<py_long>L).ob_digit)
     if Py_SIZE(L) < 0:
         mpz_neg(z, z)
 
--- src/sage/misc/parser.pyx.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/misc/parser.pyx	2018-10-14 20:18:28.000000000 -0600
@@ -96,7 +96,7 @@ def token_to_str(int token):
 
 
 cdef inline bint is_alphanumeric(char c):
-    return 'a' <= c <= 'z' or 'A' <= c <= 'Z' or '0' <= c <= '9' or c == '_'
+    return c'a' <= c <= c'z' or c'A' <= c <= c'Z' or c'0' <= c <= c'9' or c == c'_'
 
 cdef inline bint is_whitespace(char c):
     return (c != 0) & (strchr(" \t\n\r", c) != NULL)
@@ -247,23 +247,23 @@ cdef class Tokenizer:
             return EOS
 
         # dipthongs
-        if s[pos+1] == '=':
-            if s[pos] == '<':
+        if s[pos+1] == c'=':
+            if s[pos] == c'<':
                 self.pos += 2
                 return LESS_EQ
-            elif s[pos] == '>':
+            elif s[pos] == c'>':
                 self.pos += 2
                 return GREATER_EQ
-            elif s[pos] == '!':
+            elif s[pos] == c'!':
                 self.pos += 2
                 return NOT_EQ
-            elif s[pos] == '=':
+            elif s[pos] == c'=':
                 self.pos += 2
-                return '='
+                return c'='
 
-        elif s[pos] == '*' and s[pos+1] == '*':
+        elif s[pos] == c'*' and s[pos+1] == c'*':
             self.pos += 2
-            return '^'
+            return c'^'
 
         # simple tokens
         if strchr("+-*/^()=<>,[]{}!", s[pos]):
@@ -272,29 +272,29 @@ cdef class Tokenizer:
             return type
 
         # numeric literals
-        if '0' <= s[pos] <= '9' or s[pos] == '.':
+        if c'0' <= s[pos] <= c'9' or s[pos] == c'.':
             type = INT
             seen_exp = False
             seen_decimal = False
             while True:
-                if '0' <= s[pos] <= '9':
+                if c'0' <= s[pos] <= c'9':
                     pass
-                elif s[pos] == '.':
+                elif s[pos] == c'.':
                     if seen_decimal or seen_exp:
                         self.pos = pos
                         return type
                     else:
                         type = FLOAT
                         seen_decimal = True
-                elif s[pos] == 'e' or s[pos] == 'E':
+                elif s[pos] == c'e' or s[pos] == c'E':
                     if seen_exp:
                         self.pos = pos
                         return type
                     else:
                         type = FLOAT
                         seen_exp = True
-                elif s[pos] == '+' or s[pos] == '-':
-                    if not (seen_exp and (s[pos-1] == 'e' or s[pos-1] == 'E')):
+                elif s[pos] == c'+' or s[pos] == c'-':
+                    if not (seen_exp and (s[pos-1] == c'e' or s[pos-1] == c'E')):
                         self.pos = pos
                         return type
                 else:
@@ -573,13 +573,13 @@ cdef class Parser:
         """
         cdef int token
         all = []
-        if tokens.next() == '(':
-            token = ','
-            while token == ',':
+        if tokens.next() == c'(':
+            token = c','
+            while token == c',':
                 all.append(self.p_list(tokens))
                 token = tokens.next()
 
-            if token == ')':
+            if token == c')':
                 from sage.matrix.constructor import matrix
                 return matrix(all)
             else:
@@ -601,8 +601,8 @@ cdef class Parser:
             [(1, 2, 3), [a + 1, b + 2, c + 3, (d + 4,)]]
         """
         all = []
-        cdef int token = ','
-        while token == ',':
+        cdef int token = c','
+        while token == c',':
             token = tokens.peek()
             if token == MATRIX:
                 tokens.next()
@@ -615,14 +615,14 @@ cdef class Parser:
                 else:
                     tokens.backtrack()
                     obj = self.p_eqn(tokens)
-            elif token == '[':
+            elif token == c'[':
                 obj = self.p_list(tokens)
-            elif token == '(':
+            elif token == c'(':
                 obj = self.p_tuple(tokens)
             elif token == EOS:
                 return all
-            elif token == ']' or token == ')':
-                tokens.token = ','
+            elif token == c']' or token == c')':
+                tokens.token = c','
                 return all
             else:
                 obj = self.p_eqn(tokens)
@@ -646,11 +646,11 @@ cdef class Parser:
             []
         """
         cdef int token = tokens.next()
-        if token != '[':
+        if token != c'[':
             self.parse_error(tokens, "Malformed list")
         all = self.p_sequence(tokens)
         token = tokens.next()
-        if token != ']':
+        if token != c']':
             self.parse_error(tokens, "Malformed list")
         return all
 
@@ -668,20 +668,20 @@ cdef class Parser:
         cdef int start = tokens.pos
         cdef int token = tokens.next()
         cdef bint real_tuple = True
-        if token != '(':
+        if token != c'(':
             self.parse_error(tokens, "Malformed tuple")
         all = self.p_sequence(tokens)
         if len(all) == 1:
             if tokens.last() != c',':
                 real_tuple = False
         token = tokens.next()
-        if token != ')':
+        if token != c')':
             self.parse_error(tokens, "Malformed tuple")
         if real_tuple:
             return tuple(all)
         else:
             token = tokens.peek()
-            if token == ',' or token == EOS:
+            if token == c',' or token == EOS:
                 return all[0]
             else:
                 # we have to reparse the entire thing as an expression
@@ -717,15 +717,15 @@ cdef class Parser:
         """
         lhs = self.p_expr(tokens)
         cdef int op = tokens.next()
-        if op == '=':
+        if op == c'=':
             return lhs == self.p_expr(tokens)
         elif op == NOT_EQ:
             return lhs != self.p_expr(tokens)
-        elif op == '<':
+        elif op == c'<':
             return lhs < self.p_expr(tokens)
         elif op == LESS_EQ:
             return lhs <= self.p_expr(tokens)
-        elif op == '>':
+        elif op == c'>':
             return lhs > self.p_expr(tokens)
         elif op == GREATER_EQ:
             return lhs >= self.p_expr(tokens)
@@ -757,9 +757,9 @@ cdef class Parser:
         cdef int op
         operand1 = self.p_term(tokens)
         op = tokens.next()
-        while op == '+' or op == '-':
+        while op == c'+' or op == c'-':
             operand2 = self.p_term(tokens)
-            if op == '+':
+            if op == c'+':
                 operand1 = operand1 + operand2
             else:
                 operand1 = operand1 - operand2
@@ -792,17 +792,17 @@ cdef class Parser:
         operand1 = self.p_factor(tokens)
         op = tokens.next()
         if op == NAME and self.implicit_multiplication:
-            op = '*'
+            op = c'*'
             tokens.backtrack()
-        while op == '*' or op == '/':
+        while op == c'*' or op == c'/':
             operand2 = self.p_factor(tokens)
-            if op == '*':
+            if op == c'*':
                 operand1 = operand1 * operand2
             else:
                 operand1 = operand1 / operand2
             op = tokens.next()
             if op == NAME and self.implicit_multiplication:
-                op = '*'
+                op = c'*'
                 tokens.backtrack()
         tokens.backtrack()
         return operand1
@@ -826,9 +826,9 @@ cdef class Parser:
             t^11
         """
         cdef int token = tokens.next()
-        if token == '+':
+        if token == c'+':
             return self.p_factor(tokens)
-        elif token == '-':
+        elif token == c'-':
             return -self.p_factor(tokens)
         else:
             tokens.backtrack()
@@ -862,13 +862,13 @@ cdef class Parser:
         """
         operand1 = self.p_atom(tokens)
         cdef int token = tokens.next()
-        if token == '^':
+        if token == c'^':
             operand2 = self.p_factor(tokens)
             return operand1 ** operand2
-        elif token == "!":
+        elif token == c'!':
             from sage.functions.all import factorial
             operand1 = factorial(operand1)
-            if tokens.peek() == '^':
+            if tokens.peek() == c'^':
                 tokens.next()
                 operand2 = self.p_factor(tokens)
                 return operand1 ** operand2
@@ -913,20 +913,20 @@ cdef class Parser:
         elif token == NAME:
             name = tokens.last_token_string()
             token = tokens.next()
-            if token == '(':
+            if token == c'(':
                 func = self.callable_constructor(name)
                 args, kwds = self.p_args(tokens)
                 token = tokens.next()
-                if token != ')':
+                if token != c')':
                     self.parse_error(tokens, "Bad function call")
                 return func(*args, **kwds)
             else:
                 tokens.backtrack()
                 return self.variable_constructor(name)
-        elif token == '(':
+        elif token == c'(':
             expr = self.p_expr(tokens)
             token = tokens.next()
-            if token != ')':
+            if token != c')':
                 self.parse_error(tokens, "Mismatched parentheses")
             return expr
         else:
@@ -948,10 +948,10 @@ cdef class Parser:
         """
         args = []
         kwds = {}
-        if tokens.peek() == ')':
+        if tokens.peek() == c')':
             return args, kwds
-        cdef int token = ','
-        while token == ',':
+        cdef int token = c','
+        while token == c',':
             arg = self.p_arg(tokens)
             if isinstance(arg, tuple):
                 name, value = arg
@@ -993,11 +993,11 @@ cdef class Parser:
 
         """
         cdef int token = tokens.next()
-        if token == NAME and tokens.peek() == '=':
+        if token == NAME and tokens.peek() == c'=':
             name = tokens.last_token_string()
             tokens.next()
             return name, self.p_expr(tokens)
-        if token == "[" :
+        if token == c'[' :
             tokens.backtrack()
             return self.p_list(tokens)
         else:
--- src/sage/plot/plot3d/plot3d.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/plot/plot3d/plot3d.py	2018-10-17 09:03:00.049705941 -0600
@@ -188,7 +188,8 @@ class _Coordinates(object):
             Arbitrary Coordinates coordinate transform (z in terms of x, y)
         """
         import inspect
-        all_vars=inspect.getargspec(self.transform).args[1:]
+        args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = inspect.getfullargspec(self.transform)
+        all_vars=args[1:]
         if set(all_vars) != set(indep_vars + [dep_var]):
             raise ValueError('variables were specified incorrectly for this coordinate system; incorrect variables were %s'%list(set(all_vars).symmetric_difference(set(indep_vars+[dep_var]))))
         self.dep_var = dep_var
--- src/sage/plot/point.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/plot/point.py	2018-10-17 09:54:36.767621593 -0600
@@ -29,7 +29,7 @@ TESTS::
 from sage.misc.decorators import options, rename_keyword
 from sage.plot.colors import to_mpl_color
 from sage.plot.primitive import GraphicPrimitive_xydata
-import collections
+import collections.abc
 
 
 # TODO: create _allowed_options for 3D point classes to
@@ -343,7 +343,7 @@ def point(points, **kwds):
         sage: point(iter([(1,2),(3,5)]))
         Graphics object consisting of 1 graphics primitive
     """
-    if isinstance(points, collections.Iterator):
+    if isinstance(points, collections.abc.Iterator):
         points = list(points)
 
     try:
--- src/sage/repl/display/fancy_repr.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/repl/display/fancy_repr.py	2018-10-17 13:37:25.606376556 -0600
@@ -15,7 +15,7 @@ Representations of objects.
 import types
 
 from IPython.lib.pretty import (
-    _safe_getattr, _baseclass_reprs,
+    _safe_getattr,
     _type_pprinters,
 )
 
@@ -264,7 +264,7 @@ class PlainPythonRepr(ObjectReprABC):
         """
         klass = _safe_getattr(obj, '__class__', None) or type(obj)
         klass_repr = _safe_getattr(klass, '__repr__', None)
-        if klass_repr in _baseclass_reprs:
+        if klass_repr is object.__repr__:
             p.text(klass_repr(obj))
         else:
             # A user-provided repr. Find newlines and replace them with p.break_()
--- src/sage/repl/ipython_kernel/interact.py.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/repl/ipython_kernel/interact.py	2018-10-16 15:22:52.943730034 -0600
@@ -36,7 +36,7 @@ EXAMPLES::
 from ipywidgets.widgets import SelectionSlider, ValueWidget, ToggleButtons
 from ipywidgets.widgets.interaction import interactive, signature
 from copy import copy
-from collections import Iterable, Iterator
+from collections.abc import Iterable, Iterator
 from .widgets import EvalText, SageColorPicker
 from sage.structure.element import parent
 from sage.symbolic.ring import SR
--- src/sage/rings/integer.pyx.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/rings/integer.pyx	2018-10-15 14:15:05.631285493 -0600
@@ -6933,7 +6933,7 @@ cdef int mpz_set_str_python(mpz_ptr z, c
     while x[0] == c' ': x += 1  # Strip spaces
 
     # Disallow a sign here
-    if x[0] == '-' or x[0] == '+':
+    if x[0] == c'-' or x[0] == c'+':
         x = ""  # Force an error below
 
     assert base >= 2
--- src/sage/rings/real_mpfi.pyx.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/rings/real_mpfi.pyx	2018-10-15 14:22:32.912750377 -0600
@@ -1951,12 +1951,12 @@ cdef class RealIntervalFieldElement(Ring
 
         cdef long digits
         digits = strlen(lower_s)
-        if lower_s[0] == '-':
+        if lower_s[0] == c'-':
             digits -= 1
         lower_expo -= digits
 
         digits = strlen(upper_s)
-        if upper_s[0] == '-':
+        if upper_s[0] == c'-':
             digits -= 1
         upper_expo -= digits
 
@@ -2125,7 +2125,7 @@ cdef class RealIntervalFieldElement(Ring
             raise MemoryError("Unable to allocate memory for the mantissa of an interval")
         mpz_get_str(tmp_cstr, base, lower_mpz)
         digits = strlen(tmp_cstr)
-        if tmp_cstr[0] == '-':
+        if tmp_cstr[0] == c'-':
             digits -= 1
             mant_string = bytes_to_str(tmp_cstr+1)
             sign_string = bytes_to_str(b'-')
--- src/sage_setup/docbuild/ext/multidocs.py.orig	2018-08-29 08:36:07.829487630 -0600
+++ src/sage_setup/docbuild/ext/multidocs.py	2018-10-16 15:59:34.604773328 -0600
@@ -239,7 +239,7 @@ def write_citations(app, citations):
     """
     from sage.misc.temporary_file import atomic_write
     outdir = citation_dir(app)
-    with atomic_write(os.path.join(outdir, CITE_FILENAME)) as f:
+    with atomic_write(os.path.join(outdir, CITE_FILENAME), binary=True) as f:
         cPickle.dump(citations, f)
     app.info("Saved pickle file: %s" % CITE_FILENAME)
 
--- src/sage/symbolic/expression.pyx.orig	2018-08-03 05:10:09.000000000 -0600
+++ src/sage/symbolic/expression.pyx	2018-10-15 14:25:08.769821636 -0600
@@ -12920,7 +12920,7 @@ cdef class hold_class:
             sage: SR(2)^5
             32
         """
-        g_set_state('hold', True)
+        g_set_state(b'hold', True)
 
     def __exit__(self, *args):
         """
@@ -12933,7 +12933,7 @@ cdef class hold_class:
             sage: SR(2)^5
             32
         """
-        g_set_state('hold', False)
+        g_set_state(b'hold', False)
 
     def start(self):
         """
--- src/setup.py.orig	2018-08-29 08:35:19.955079610 -0600
+++ src/setup.py	2018-10-16 08:24:24.587609650 -0600
@@ -284,6 +284,7 @@ class sage_build_cython(Command):
             cdivision=True,
             embedsignature=True,
             fast_getattr=True,
+            language_level=3,
             preliminary_late_includes_cy28=True,
             profile=self.profile,
         )
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux