Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-133546: Makere.Match a well-roundedSequence type#133549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
vberlier wants to merge13 commits intopython:mainfromvberlier:gh-133546
Closed
Changes from1 commit
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add missing braces
  • Loading branch information
@vberlier
vberlier committedMay 11, 2025
commit70b73e4be41a0db5fb0e7411a20cd8970b4a28f1
21 changes: 14 additions & 7 deletionsModules/_sre/sre.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2657,8 +2657,9 @@ _sre_SRE_Match_index_impl(MatchObject *self, PyObject *value,

if (start < 0) {
start += self->groups;
if (start < 0)
if (start < 0) {
start = 0;
}
}
if (stop < 0) {
stop += self->groups;
Expand All@@ -2668,14 +2669,17 @@ _sre_SRE_Match_index_impl(MatchObject *self, PyObject *value,
}
for (i = start; i < stop; i++) {
PyObject* group = match_getslice_by_index(self, i, Py_None);
if (group == NULL)
if (group == NULL) {
return NULL;
}
int cmp = PyObject_RichCompareBool(group, value, Py_EQ);
Py_DECREF(group);
if (cmp > 0)
if (cmp > 0) {
return PyLong_FromSsize_t(i);
else if (cmp < 0)
}
else if (cmp < 0) {
return NULL;
}
}
PyErr_SetString(PyExc_ValueError, "match.index(x): x not in match");
return NULL;
Expand All@@ -2699,14 +2703,17 @@ _sre_SRE_Match_count_impl(MatchObject *self, PyObject *value)

for (i = 0; i < self->groups; i++) {
PyObject* group = match_getslice_by_index(self, i, Py_None);
if (group == NULL)
if (group == NULL) {
return NULL;
}
int cmp = PyObject_RichCompareBool(group, value, Py_EQ);
Py_DECREF(group);
if (cmp > 0)
if (cmp > 0) {
count++;
else if (cmp < 0)
}
else if (cmp < 0) {
return NULL;
}
}
return PyLong_FromSsize_t(count);
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp