Skip to content

Commit c0b9a69

Browse files
Support an internal plain text default filter.
1 parent 67b7fb9 commit c0b9a69

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Python/_warnings.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,20 @@ check_matched(PyInterpreterState *interp, PyObject *obj, PyObject *arg, PyObject
180180
if (obj == Py_None)
181181
return 1;
182182

183-
if (arg != NULL) {
184-
/* An internal plain text default filter must match exactly */
185-
if (PyUnicode_CheckExact(obj)) {
186-
int cmp_result = PyUnicode_Compare(obj, arg);
187-
if (cmp_result == -1 && PyErr_Occurred()) {
188-
return -1;
189-
}
190-
return !cmp_result;
183+
/* An internal plain text default filter must match exactly */
184+
if (PyUnicode_CheckExact(obj)) {
185+
if (arg == NULL) {
186+
return 0;
187+
}
188+
int cmp_result = PyUnicode_Compare(obj, arg);
189+
if (cmp_result == -1 && PyErr_Occurred()) {
190+
return -1;
191191
}
192+
return !cmp_result;
193+
}
192194

193-
/* Otherwise assume a regex filter and call its match() method */
195+
/* Otherwise assume a regex filter and call its match() method */
196+
if (arg != NULL) {
194197
result = PyObject_CallMethodOneArg(obj, &_Py_ID(match), arg);
195198
}
196199
else {

0 commit comments

Comments
 (0)