Skip to content
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Support an internal plain text default filter.
  • Loading branch information
serhiy-storchaka committed Oct 22, 2025
commit c0b9a69f8e6e1fa00a6b611611b18f464522b39e
21 changes: 12 additions & 9 deletions Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,20 @@ check_matched(PyInterpreterState *interp, PyObject *obj, PyObject *arg, PyObject
if (obj == Py_None)
return 1;

if (arg != NULL) {
/* An internal plain text default filter must match exactly */
if (PyUnicode_CheckExact(obj)) {
int cmp_result = PyUnicode_Compare(obj, arg);
if (cmp_result == -1 && PyErr_Occurred()) {
return -1;
}
return !cmp_result;
/* An internal plain text default filter must match exactly */
if (PyUnicode_CheckExact(obj)) {
if (arg == NULL) {
return 0;
}
int cmp_result = PyUnicode_Compare(obj, arg);
if (cmp_result == -1 && PyErr_Occurred()) {
return -1;
}
return !cmp_result;
}

/* Otherwise assume a regex filter and call its match() method */
/* Otherwise assume a regex filter and call its match() method */
if (arg != NULL) {
result = PyObject_CallMethodOneArg(obj, &_Py_ID(match), arg);
}
else {
Expand Down
Loading