Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1c6c90fc
Commit
1c6c90fc
authored
Dec 23, 2012
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16443: Add docstrings to regular expression match objects.
Patch by Anton Kasyanov.
parent
f8a6b005
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
9 deletions
+53
-9
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_sre.c
Modules/_sre.c
+49
-9
No files found.
Misc/ACKS
View file @
1c6c90fc
...
@@ -499,6 +499,7 @@ Tamito Kajiyama
...
@@ -499,6 +499,7 @@ Tamito Kajiyama
Peter van Kampen
Peter van Kampen
Jacob Kaplan-Moss
Jacob Kaplan-Moss
Piotr Kasprzyk
Piotr Kasprzyk
Anton Kasyanov
Lou Kates
Lou Kates
Hiroaki Kawai
Hiroaki Kawai
Sebastien Keim
Sebastien Keim
...
...
Misc/NEWS
View file @
1c6c90fc
...
@@ -160,6 +160,9 @@ Core and Builtins
...
@@ -160,6 +160,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #16443: Add docstrings to regular expression match objects.
Patch by Anton Kasyanov.
- Issue #8853: Allow port to be of type long for socket.getaddrinfo().
- Issue #8853: Allow port to be of type long for socket.getaddrinfo().
- Issue #16597: In buffered and text IO, call close() on the underlying stream
- Issue #16597: In buffered and text IO, call close() on the underlying stream
...
...
Modules/_sre.c
View file @
1c6c90fc
...
@@ -3545,14 +3545,54 @@ match_deepcopy(MatchObject* self, PyObject* memo)
...
@@ -3545,14 +3545,54 @@ match_deepcopy(MatchObject* self, PyObject* memo)
#endif
#endif
}
}
static
struct
PyMethodDef
match_methods
[]
=
{
PyDoc_STRVAR
(
match_doc
,
{
"group"
,
(
PyCFunction
)
match_group
,
METH_VARARGS
},
"The result of re.match() and re.search().
\n
\
{
"start"
,
(
PyCFunction
)
match_start
,
METH_VARARGS
},
Match objects always have a boolean value of True."
);
{
"end"
,
(
PyCFunction
)
match_end
,
METH_VARARGS
},
{
"span"
,
(
PyCFunction
)
match_span
,
METH_VARARGS
},
PyDoc_STRVAR
(
match_group_doc
,
{
"groups"
,
(
PyCFunction
)
match_groups
,
METH_VARARGS
|
METH_KEYWORDS
},
"group([group1, ...]) -> str or tuple.
\n
\
{
"groupdict"
,
(
PyCFunction
)
match_groupdict
,
METH_VARARGS
|
METH_KEYWORDS
},
Return subgroup(s) of the match by indices or names.
\n
\
{
"expand"
,
(
PyCFunction
)
match_expand
,
METH_O
},
For 0 returns the entire match."
);
PyDoc_STRVAR
(
match_start_doc
,
"start([group=0]) -> int.
\n
\
Return index of the start of the substring matched by group."
);
PyDoc_STRVAR
(
match_end_doc
,
"end([group=0]) -> int.
\n
\
Return index of the end of the substring matched by group."
);
PyDoc_STRVAR
(
match_span_doc
,
"span([group]) -> tuple.
\n
\
For MatchObject m, return the 2-tuple (m.start(group), m.end(group))."
);
PyDoc_STRVAR
(
match_groups_doc
,
"groups([default=None]) -> tuple.
\n
\
Return a tuple containing all the subgroups of the match, from 1.
\n
\
The default argument is used for groups
\n
\
that did not participate in the match"
);
PyDoc_STRVAR
(
match_groupdict_doc
,
"groupdict([default=None]) -> dict.
\n
\
Return a dictionary containing all the named subgroups of the match,
\n
\
keyed by the subgroup name. The default argument is used for groups
\n
\
that did not participate in the match"
);
PyDoc_STRVAR
(
match_expand_doc
,
"expand(template) -> str.
\n
\
Return the string obtained by doing backslash substitution
\n
\
on the string template, as done by the sub() method."
);
static
PyMethodDef
match_methods
[]
=
{
{
"group"
,
(
PyCFunction
)
match_group
,
METH_VARARGS
,
match_group_doc
},
{
"start"
,
(
PyCFunction
)
match_start
,
METH_VARARGS
,
match_start_doc
},
{
"end"
,
(
PyCFunction
)
match_end
,
METH_VARARGS
,
match_end_doc
},
{
"span"
,
(
PyCFunction
)
match_span
,
METH_VARARGS
,
match_span_doc
},
{
"groups"
,
(
PyCFunction
)
match_groups
,
METH_VARARGS
|
METH_KEYWORDS
,
match_groups_doc
},
{
"groupdict"
,
(
PyCFunction
)
match_groupdict
,
METH_VARARGS
|
METH_KEYWORDS
,
match_groupdict_doc
},
{
"expand"
,
(
PyCFunction
)
match_expand
,
METH_O
,
match_expand_doc
},
{
"__copy__"
,
(
PyCFunction
)
match_copy
,
METH_NOARGS
},
{
"__copy__"
,
(
PyCFunction
)
match_copy
,
METH_NOARGS
},
{
"__deepcopy__"
,
(
PyCFunction
)
match_deepcopy
,
METH_O
},
{
"__deepcopy__"
,
(
PyCFunction
)
match_deepcopy
,
METH_O
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
...
@@ -3632,7 +3672,7 @@ static PyTypeObject Match_Type = {
...
@@ -3632,7 +3672,7 @@ static PyTypeObject Match_Type = {
0
,
/* tp_setattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
,
Py_TPFLAGS_DEFAULT
,
0
,
/* tp_doc */
match_doc
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_richcompare */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment