Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 367a267

Browse files
authored
Merge pull request #21454 from timhoffm/fix-pyparsing
Fix error with pyparsing 3 for 3.5.x
2 parents 336c285 + 90c7afd commit 367a267

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import numpy as np
1515
from pyparsing import (
16-
Combine, Empty, FollowedBy, Forward, Group, Literal, oneOf, OneOrMore,
16+
Combine, Empty, Forward, Group, Literal, oneOf, OneOrMore,
1717
Optional, ParseBaseException, ParseFatalException, ParserElement,
1818
ParseResults, QuotedString, Regex, StringEnd, Suppress, ZeroOrMore)
1919

@@ -2044,7 +2044,7 @@ def __init__(self):
20442044
p.accentprefixed <<= Suppress(p.bslash) + oneOf(self._accentprefixed)
20452045
p.symbol_name <<= (
20462046
Combine(p.bslash + oneOf(list(tex2uni)))
2047-
+ FollowedBy(Regex("[^A-Za-z]").leaveWhitespace() | StringEnd())
2047+
+ Suppress(Regex("(?=[^A-Za-z]|$)").leaveWhitespace())
20482048
)
20492049
p.symbol <<= (p.single_symbol | p.symbol_name).leaveWhitespace()
20502050

lib/matplotlib/tests/test_mathtext.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ def test_fontinfo():
250250
(r'$\leftF$', r'Expected a delimiter'),
251251
(r'$\rightF$', r'Unknown symbol: \rightF'),
252252
(r'$\left(\right$', r'Expected a delimiter'),
253-
(r'$\left($', r'Expected "\right"'),
253+
# PyParsing 2 uses double quotes, PyParsing 3 uses single quotes and an
254+
# extra backslash.
255+
(r'$\left($', re.compile(r'Expected ("|\'\\)\\right["\']')),
254256
(r'$\dfrac$', r'Expected \dfrac{num}{den}'),
255257
(r'$\dfrac{}{}$', r'Expected \dfrac{num}{den}'),
256258
(r'$\overset$', r'Expected \overset{body}{annotation}'),
@@ -281,8 +283,8 @@ def test_fontinfo():
281283
)
282284
def test_mathtext_exceptions(math, msg):
283285
parser = mathtext.MathTextParser('agg')
284-
285-
with pytest.raises(ValueError, match=re.escape(msg)):
286+
match = re.escape(msg) if isinstance(msg, str) else msg
287+
with pytest.raises(ValueError, match=match):
286288
parser.parse(math)
287289

288290

requirements/doc/doc-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ ipython
1313
ipywidgets
1414
numpydoc>=0.8
1515
packaging>=20
16-
pyparsing<3.0.0
1716
pydata-sphinx-theme>=0.6.0
1817
sphinxcontrib-svg2pdfconverter>=1.1.0
1918
sphinx-gallery>=0.10

requirements/testing/all.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
certifi
44
coverage
5-
pyparsing<3.0.0
65
pytest!=4.6.0,!=5.4.0
76
pytest-cov
87
pytest-rerunfailures

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def make_release_tree(self, base_dir, files):
326326
"numpy>=1.17",
327327
"packaging>=20.0",
328328
"pillow>=6.2.0",
329-
"pyparsing>=2.2.1,<3.0.0",
329+
"pyparsing>=2.2.1",
330330
"python-dateutil>=2.7",
331331
] + (
332332
# Installing from a git checkout.

0 commit comments

Comments
 (0)