]> git.pld-linux.org Git - packages/python-sympy.git/blob - 0001-Fix-more-compatibility-issues-with-Python3.8.patch
- test suite fixes
[packages/python-sympy.git] / 0001-Fix-more-compatibility-issues-with-Python3.8.patch
1 From 5ea93bc9ab7ae9829ed596e2d53976962164ba78 Mon Sep 17 00:00:00 2001
2 From: Vighnesh Shenoy <vighneshq@gmail.com>
3 Date: Sun, 9 Jun 2019 23:34:21 +0530
4 Subject: [PATCH] Issue #16977, fix more compatibility issues with Python3.8.
5
6 xml.dom.minidom preserves attribute order in Python3.8 which causes
7 some test failures. Modified the order of attribute insertion to
8 ensure that tests run on both 3.8 & earlier versions. Modified the use
9 of officially removed time.clock with a conditional import in
10 sympy/core/compatibility.py
11 ---
12  examples/advanced/pidigits.py            |  2 +-
13  examples/advanced/pyglet_plotting.py     |  4 ++--
14  sympy/core/compatibility.py              |  5 ++++
15  sympy/plotting/pygletplot/plot_window.py |  2 +-
16  sympy/printing/mathml.py                 | 30 ++++++++++++------------
17  5 files changed, 24 insertions(+), 19 deletions(-)
18
19 diff --git a/examples/advanced/pidigits.py b/examples/advanced/pidigits.py
20 index 430ea5aaf83..e444ba2276b 100755
21 --- a/examples/advanced/pidigits.py
22 +++ b/examples/advanced/pidigits.py
23 @@ -10,7 +10,7 @@ from mpmath import libmp, pi
24  from mpmath import functions as mpf_funs
25  
26  import math
27 -from time import clock
28 +from sympy.core.compatibility import clock
29  import sys
30  
31  
32 diff --git a/examples/advanced/pyglet_plotting.py b/examples/advanced/pyglet_plotting.py
33 index 16d13ac5137..c12ed54f5b1 100755
34 --- a/examples/advanced/pyglet_plotting.py
35 +++ b/examples/advanced/pyglet_plotting.py
36 @@ -8,10 +8,10 @@ Suggested Usage:    python -i pyglet_plo
37  
38  
39  from sympy import symbols, sin, cos, pi, sqrt
40 -from sympy.core.compatibility import range
41 +from sympy.core.compatibility import range, clock
42  from sympy.plotting.pygletplot import PygletPlot
43  
44 -from time import sleep, clock
45 +from time import sleep
46  
47  
48  def main():
49 diff --git a/sympy/core/compatibility.py b/sympy/core/compatibility.py
50 index 2827b40ca17..9b6a644d847 100644
51 --- a/sympy/core/compatibility.py
52 +++ b/sympy/core/compatibility.py
53 @@ -945,3 +945,8 @@ try:
54  except ImportError:  # Python 2.7
55      def filterfalse(pred, itr):
56          return filter(lambda x: not pred(x), itr)
57 +
58 +try:
59 +    from time import clock
60 +except ImportError: # Python 3.8+
61 +    from time import perf_counter as clock
62 diff --git a/sympy/plotting/pygletplot/plot_window.py b/sympy/plotting/pygletplot/plot_window.py
63 index 91bf42cc532..193093229b4 100644
64 --- a/sympy/plotting/pygletplot/plot_window.py
65 +++ b/sympy/plotting/pygletplot/plot_window.py
66 @@ -1,6 +1,6 @@
67  from __future__ import print_function, division
68  
69 -from time import clock
70 +from sympy.core.compatibility import clock
71  
72  import pyglet.gl as pgl
73  
74 diff --git a/sympy/printing/mathml.py b/sympy/printing/mathml.py
75 index c1eba60b3d4..e5012efe74d 100644
76 --- a/sympy/printing/mathml.py
77 +++ b/sympy/printing/mathml.py
78 @@ -654,8 +654,8 @@ class MathMLPresentationPrinter(MathMLPr
79              return table
80          brac = self.dom.createElement('mfenced')
81          if self._settings["mat_delim"] == "[":
82 -            brac.setAttribute('open', '[')
83              brac.setAttribute('close', ']')
84 +            brac.setAttribute('open', '[')
85          brac.appendChild(table)
86          return brac
87  
88 @@ -961,8 +961,8 @@ class MathMLPresentationPrinter(MathMLPr
89  
90      def _print_AccumulationBounds(self, i):
91          brac = self.dom.createElement('mfenced')
92 -        brac.setAttribute('open', u'\u27e8')
93          brac.setAttribute('close', u'\u27e9')
94 +        brac.setAttribute('open', u'\u27e8')
95          brac.appendChild(self._print(i.min))
96          brac.appendChild(self._print(i.max))
97          return brac
98 @@ -1106,19 +1106,19 @@ class MathMLPresentationPrinter(MathMLPr
99          brac = self.dom.createElement('mfenced')
100          if i.start == i.end:
101              # Most often, this type of Interval is converted to a FiniteSet
102 -            brac.setAttribute('open', '{')
103              brac.setAttribute('close', '}')
104 +            brac.setAttribute('open', '{')
105              brac.appendChild(self._print(i.start))
106          else:
107 -            if i.left_open:
108 -                brac.setAttribute('open', '(')
109 -            else:
110 -                brac.setAttribute('open', '[')
111 -
112              if i.right_open:
113                  brac.setAttribute('close', ')')
114              else:
115                  brac.setAttribute('close', ']')
116 +
117 +            if i.left_open:
118 +                brac.setAttribute('open', '(')
119 +            else:
120 +                brac.setAttribute('open', '[')
121              brac.appendChild(self._print(i.start))
122              brac.appendChild(self._print(i.end))
123  
124 @@ -1128,8 +1128,8 @@ class MathMLPresentationPrinter(MathMLPr
125      def _print_Abs(self, expr, exp=None):
126          mrow = self.dom.createElement('mrow')
127          x = self.dom.createElement('mfenced')
128 -        x.setAttribute('open', '|')
129          x.setAttribute('close', '|')
130 +        x.setAttribute('open', '|')
131          x.appendChild(self._print(expr.args[0]))
132          mrow.appendChild(x)
133          return mrow
134 @@ -1191,8 +1191,8 @@ class MathMLPresentationPrinter(MathMLPr
135      def _print_set(self, s):
136          items = sorted(s, key=default_sort_key)
137          brac = self.dom.createElement('mfenced')
138 -        brac.setAttribute('open', '{')
139          brac.setAttribute('close', '}')
140 +        brac.setAttribute('open', '{')
141          for item in items:
142              brac.appendChild(self._print(item))
143          return brac
144 @@ -1309,8 +1309,8 @@ class MathMLPresentationPrinter(MathMLPr
145      def _print_Range(self, s):
146          dots = u"\u2026"
147          brac = self.dom.createElement('mfenced')
148 -        brac.setAttribute('open', '{')
149          brac.setAttribute('close', '}')
150 +        brac.setAttribute('open', '{')
151  
152          if s.start.is_infinite:
153              printset = dots, s[-1] - s.step, s[-1]
154 @@ -1507,8 +1507,8 @@ class MathMLPresentationPrinter(MathMLPr
155          power = expr.args[2]
156          sup = self.dom.createElement('msup')
157          brac = self.dom.createElement('mfenced')
158 -        brac.setAttribute('open', u'\u27e8')
159          brac.setAttribute('close', u'\u27e9')
160 +        brac.setAttribute('open', u'\u27e8')
161          brac.appendChild(self._print(shift))
162          sup.appendChild(brac)
163          sup.appendChild(self._print(power))
164 @@ -1674,8 +1674,8 @@ class MathMLPresentationPrinter(MathMLPr
165      def _print_floor(self, e):
166          mrow = self.dom.createElement('mrow')
167          x = self.dom.createElement('mfenced')
168 -        x.setAttribute('open', u'\u230A')
169          x.setAttribute('close', u'\u230B')
170 +        x.setAttribute('open', u'\u230A')
171          x.appendChild(self._print(e.args[0]))
172          mrow.appendChild(x)
173          return mrow
174 @@ -1683,8 +1683,8 @@ class MathMLPresentationPrinter(MathMLPr
175      def _print_ceiling(self, e):
176          mrow = self.dom.createElement('mrow')
177          x = self.dom.createElement('mfenced')
178 -        x.setAttribute('open', u'\u2308')
179          x.setAttribute('close', u'\u2309')
180 +        x.setAttribute('open', u'\u2308')
181          x.appendChild(self._print(e.args[0]))
182          mrow.appendChild(x)
183          return mrow
184 @@ -1727,8 +1727,8 @@ class MathMLPresentationPrinter(MathMLPr
185          x = self.dom.createElement('msub')
186          x.appendChild(self.parenthesize(e.parent, PRECEDENCE["Atom"], strict = True))
187          brac = self.dom.createElement('mfenced')
188 -        brac.setAttribute("open", "")
189          brac.setAttribute("close", "")
190 +        brac.setAttribute("open", "")
191          for i in e.indices:
192              brac.appendChild(self._print(i))
193          x.appendChild(brac)
This page took 0.065879 seconds and 3 git commands to generate.