diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-10-29 15:58:59 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-10-29 15:58:59 (GMT) |
commit | 55e614a2a8cc5b7a5af5795f87349ce3bf98fe84 (patch) | |
tree | c281fdc27b3b8620220319eee923ed008bcc2398 | |
parent | bad8d4bb53577fbea939d3490713dc9d941eb27f (diff) | |
download | cpython-55e614a2a8cc5b7a5af5795f87349ce3bf98fe84.zip cpython-55e614a2a8cc5b7a5af5795f87349ce3bf98fe84.tar.gz cpython-55e614a2a8cc5b7a5af5795f87349ce3bf98fe84.tar.bz2 |
Issue #11957: Explicit parameter name when calling re.split() and re.sub()
-rw-r--r-- | Lib/http/cookiejar.py | 2 | ||||
-rw-r--r-- | Lib/test/test_re.py | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py index d563350..4135ebf 100644 --- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -478,7 +478,7 @@ def parse_ns_headers(ns_headers): if "=" not in param: k, v = param, None else: - k, v = re.split(r"\s*=\s*", param, 1) + k, v = re.split(r"\s*=\s*", param, maxsplit=1) k = k.lstrip() if ii != 0: lc = k.lower() diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 0e4fa88..dfc797c 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -83,7 +83,7 @@ class ReTests(unittest.TestCase): self.assertEqual(re.sub("(?i)b+", "x", "bbbb BBBB"), 'x x') self.assertEqual(re.sub(r'\d+', self.bump_num, '08.2 -2 23x99y'), '9.3 -3 24x100y') - self.assertEqual(re.sub(r'\d+', self.bump_num, '08.2 -2 23x99y', 3), + self.assertEqual(re.sub(r'\d+', self.bump_num, '08.2 -2 23x99y', count=3), '9.3 -3 23x99y') self.assertEqual(re.sub('.', lambda m: r"\n", 'x'), '\\n') @@ -179,7 +179,7 @@ class ReTests(unittest.TestCase): def test_qualified_re_sub(self): self.assertEqual(re.sub('a', 'b', 'aaaaa'), 'bbbbb') - self.assertEqual(re.sub('a', 'b', 'aaaaa', 1), 'baaaa') + self.assertEqual(re.sub('a', 'b', 'aaaaa', count=1), 'baaaa') def test_bug_114660(self): self.assertEqual(re.sub(r'(\S)\s+(\S)', r'\1 \2', 'hello there'), @@ -244,7 +244,7 @@ class ReTests(unittest.TestCase): self.assertEqual(re.subn("b+", "x", "bbbb BBBB"), ('x BBBB', 1)) self.assertEqual(re.subn("b+", "x", "xyz"), ('xyz', 0)) self.assertEqual(re.subn("b*", "x", "xyz"), ('xxxyxzx', 4)) - self.assertEqual(re.subn("b*", "x", "xyz", 2), ('xxxyz', 2)) + self.assertEqual(re.subn("b*", "x", "xyz", count=2), ('xxxyz', 2)) def test_re_split(self): for string in ":a:b::c", S(":a:b::c"): @@ -282,11 +282,11 @@ class ReTests(unittest.TestCase): ['', 'a', '', '', 'c']) def test_qualified_re_split(self): - self.assertEqual(re.split(":", ":a:b::c", 2), ['', 'a', 'b::c']) - self.assertEqual(re.split(':', 'a:b:c:d', 2), ['a', 'b', 'c:d']) - self.assertEqual(re.split("(:)", ":a:b::c", 2), + self.assertEqual(re.split(":", ":a:b::c", maxsplit=2), ['', 'a', 'b::c']) + self.assertEqual(re.split(':', 'a:b:c:d', maxsplit=2), ['a', 'b', 'c:d']) + self.assertEqual(re.split("(:)", ":a:b::c", maxsplit=2), ['', ':', 'a', ':', 'b::c']) - self.assertEqual(re.split("(:*)", ":a:b::c", 2), + self.assertEqual(re.split("(:*)", ":a:b::c", maxsplit=2), ['', ':', 'a', ':', 'b::c']) def test_re_findall(self): |