8000 gh-91102: Port 8-argument _warnings.warn_explicit to Argument Clinic … · python/cpython@41e0585 · GitHub
[go: up one dir, main page]

Skip to content

Commit 41e0585

Browse files
gh-91102: Port 8-argument _warnings.warn_explicit to Argument Clinic (#92891)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
1 parent 6dadf6c commit 41e0585

File tree

3 files changed

+106
-25
lines changed

3 files changed

+106
-25
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:meth:`_warnings.warn_explicit` is ported to Argument Clinic.

Python/_warnings.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,28 +1030,31 @@ get_source_line(PyInterpreterState *interp, PyObject *module_globals, int lineno
10301030
return source_line;
10311031
}
10321032

1033+
/*[clinic input]
1034+
warn_explicit as warnings_warn_explicit
1035+
1036+
message: object
1037+
category: object
1038+
filename: unicode
1039+
lineno: int
1040+
module as mod: object = NULL
1041+
registry: object = None
1042+
module_globals: object = None
1043+
source as sourceobj: object = None
1044+
1045+
Issue a warning, or maybe ignore it or raise an exception.
1046+
[clinic start generated code]*/
1047+
10331048
static PyObject *
1034-
warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
1049+
warnings_warn_explicit_impl(PyObject *module, PyObject *message,
1050+
PyObject *category, PyObject *filename,
1051+
int lineno, PyObject *mod, PyObject *registry,
1052+
PyObject *module_globals, PyObject *sourceobj)
1053+
/*[clinic end generated code: output=c49c62b15a49a186 input=df6eeb8b45e712f1]*/
10351054
{
1036-
static char *kwd_list[] = {"message", "category", "filename", "lineno",
1037-
"module", "registry", "module_globals",
1038-
"source", 0};
1039-
PyObject *message;
1040-
PyObject *category;
1041-
PyObject *filename;
1042-
int lineno;
1043-
PyObject *module = NULL;
1044-
PyObject *registry = NULL;
1045-
PyObject *module_globals = NULL;
1046-
PyObject *sourceobj = NULL;
10471055
PyObject *source_line = NULL;
10481056
PyObject *returned;
10491057

1050-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOUi|OOOO:warn_explicit",
1051-
kwd_list, &message, &category, &filename, &lineno, &module,
1052-
&registry, &module_globals, &sourceobj))
1053-
return NULL;
1054-
10551058
PyThreadState *tstate = get_current_tstate();
10561059
if (tstate == NULL) {
10571060
return NULL;
@@ -1070,8 +1073,8 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
10701073
return NULL;
10711074
}
10721075
}
1073-
returned = warn_explicit(tstate, category, message, filename, lineno, module,
1074-
registry, source_line, sourceobj);
1076+
returned = warn_explicit(tstate, category, message, filename, lineno,
1077+
mod, registry, source_line, sourceobj);
10751078
Py_XDECREF(source_line);
10761079
return returned;
10771080
}
@@ -1331,13 +1334,9 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro)
13311334
}
13321335
}
13331336

1334-
PyDoc_STRVAR(warn_explicit_doc,
1335-
"Low-level interface to warnings functionality.");
1336-
13371337
static PyMethodDef warnings_functions[] = {
13381338
WARNINGS_WARN_METHODDEF
1339-
{"warn_explicit", _PyCFunction_CAST(warnings_warn_explicit),
1340-
METH_VARARGS | METH_KEYWORDS, warn_explicit_doc},
1339+
WARNINGS_WARN_EXPLICIT_METHODDEF
13411340
{"_filters_mutated", _PyCFunction_CAST(warnings_filters_mutated), METH_NOARGS,
13421341
NULL},
13431342
/* XXX(brett.cannon): add showwarning? */

Python/clinic/_warnings.c.h

Lines changed: 82 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0