gnu: neomutt: Update to 20180223.
[jackhill/guix/guix.git] / gnu / packages / patches / python-parse-too-many-fields.patch
CommitLineData
aa6c09ed
EF
1From 32f15cfefb7c7b6476360ac65cba807aa3dfccfa Mon Sep 17 00:00:00 2001
2From: David King <dking@redhat.com>
3Date: Mon, 14 Dec 2015 09:58:19 +0000
4Subject: [PATCH] Fix test_too_many_fields with Python 3.5
5
6taken from https://github.com/r1chardj0n3s/parse/pull/34
7
8Python versions before 3.5 had a limit of 100 groups in regular
9expressions. This limit was removed during 3.5 development:
10
11http://bugs.python.org/issue22437
12https://hg.python.org/cpython/rev/0b85ea4bd1af
13
14The test_too_many_fields test asserts that the limit exists by
15attempting to parse a string with 15 fields, which triggers the 100
16named groups limit.
17
18Adjust the test so that if first checks to see whether the limit of 100
19named groups exists, and only assert that parsing 15 fields fails if
20that is the case.
21---
22 test_parse.py | 10 ++++++++--
23 1 file changed, 8 insertions(+), 2 deletions(-)
24
25diff --git a/test_parse.py b/test_parse.py
26index c524349..1d50568 100755
27--- a/test_parse.py
28+++ b/test_parse.py
29@@ -6,6 +6,7 @@
30
31 import unittest
32 from datetime import datetime, time
33+import re
34
35 import parse
36
37@@ -624,8 +625,13 @@ def test_mixed_type_variant(self):
38 self.assertEqual(r.fixed[21], 'spam')
39
40 def test_too_many_fields(self):
41- p = parse.compile('{:ti}' * 15)
42- self.assertRaises(parse.TooManyFields, p.parse, '')
43+ # Python 3.5 removed the limit of 100 named groups in a regular expression,
44+ # so only test for the exception if the limit exists.
45+ try:
46+ re.compile("".join("(?P<n{n}>{n}-)".format(n=i) for i in range(101)))
47+ except AssertionError:
48+ p = parse.compile('{:ti}' * 15)
49+ self.assertRaises(parse.TooManyFields, p.parse, '')
50
51
52 class TestSearch(unittest.TestCase):