summaryrefslogtreecommitdiff
path: root/Modules/_sre.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-06-18 16:48:07 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-06-18 16:48:07 +0300
commit977b3ac1c1cf18ce8967503ac7a8638a819a5c22 (patch)
treee17173039c613e2d2c22387397bf01fd99ace433 /Modules/_sre.c
parent3583c3bd1dae286144ff3cc1ccc7982a8a5966e7 (diff)
downloadcpython-git-977b3ac1c1cf18ce8967503ac7a8638a819a5c22.tar.gz
Issue #27177: Match objects in the re module now support index-like objects
as group indices. Based on patches by Jeroen Demeyer and Xiang Zhang.
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r--Modules/_sre.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index fb0ab033c5..d379363729 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -2049,8 +2049,9 @@ match_getindex(MatchObject* self, PyObject* index)
/* Default value */
return 0;
- if (PyLong_Check(index))
- return PyLong_AsSsize_t(index);
+ if (PyIndex_Check(index)) {
+ return PyNumber_AsSsize_t(index, NULL);
+ }
i = -1;