summaryrefslogtreecommitdiff
path: root/Lib/re.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-15 15:40:29 +0000
committerGuido van Rossum <guido@python.org>1997-07-15 15:40:29 +0000
commit7cc550afe2e9f8bb750a84a1986e8489f3ec8dc4 (patch)
tree74348bd929fc1ffea8b70435a3e2d666a8fb9196 /Lib/re.py
parentedca46019b9fdbb3ab70d0eba380b2914b31a16a (diff)
downloadcpython-7cc550afe2e9f8bb750a84a1986e8489f3ec8dc4.tar.gz
Fix group() -- should be tuple even when re has exactly one group.
Diffstat (limited to 'Lib/re.py')
-rw-r--r--Lib/re.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/re.py b/Lib/re.py
index e0d363f8a2..2e1b9205f0 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -160,6 +160,9 @@ class MatchObject:
def group(self, *groups):
if len(groups) == 0:
groups = range(1, self.re.num_regs)
+ use_all = 1
+ else:
+ use_all = 0
result = []
for g in groups:
if type(g) == type(''):
@@ -171,7 +174,7 @@ class MatchObject:
result.append(None)
else:
result.append(self.string[self.regs[g][0]:self.regs[g][1]])
- if len(result) > 1:
+ if use_all or len(result) > 1:
return tuple(result)
elif len(result) == 1:
return result[0]