Skip to content

Commit 2c4d0fd

Browse files
committed
Use argument clinic
1 parent a259ba4 commit 2c4d0fd

File tree

6 files changed

+185
-40
lines changed

6 files changed

+185
-40
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ struct _Py_global_strings {
411411
STRUCT_FOR_ID(errors)
412412
STRUCT_FOR_ID(event)
413413
STRUCT_FOR_ID(eventmask)
414+
STRUCT_FOR_ID(events)
414415
STRUCT_FOR_ID(exc_type)
415416
STRUCT_FOR_ID(exc_value)
416417
STRUCT_FOR_ID(excepthook)
@@ -748,6 +749,7 @@ struct _Py_global_strings {
748749
STRUCT_FOR_ID(times)
749750
STRUCT_FOR_ID(timetuple)
750751
STRUCT_FOR_ID(timeunit)
752+
STRUCT_FOR_ID(tool)
751753
STRUCT_FOR_ID(top)
752754
STRUCT_FOR_ID(trace_callback)
753755
STRUCT_FOR_ID(traceback)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/clinic/codeobject.c.h

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

Objects/codeobject.c

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,43 +1570,6 @@ code_offset_to_position(PyObject *self, PyObject* offset)
15701570
_source_offset_converter, &pi.pi_endcolumn);
15711571
}
15721572

1573-
static PyObject*
1574-
code_get_local_events(PyObject *self, PyObject* tool) {
1575-
int tool_id;
1576-
int err = PyLong_AsInt32(tool, &tool_id);
1577-
if (err != 0) {
1578-
return NULL;
1579-
}
1580-
_PyMonitoringEventSet events;
1581-
err = _PyMonitoring_GetLocalEvents(self, tool_id, &events);
1582-
if (err != 0) {
1583-
return NULL;
1584-
}
1585-
return PyLong_FromUInt32(events);
1586-
}
1587-
1588-
static PyObject*
1589-
code_set_local_events(PyObject *self, PyObject *const *args, Py_ssize_t nargs) {
1590-
int tool_id;
1591-
_PyMonitoringEventSet events;
1592-
if (!_PyArg_CheckPositional("__set_local_events__", nargs, 2, 2)) {
1593-
return NULL;
1594-
}
1595-
int err = PyLong_AsInt32(args[0], &tool_id);
1596-
if (err != 0) {
1597-
return NULL;
1598-
}
1599-
err = PyLong_AsUInt32(args[1], &events);
1600-
if (err != 0) {
1601-
return NULL;
1602-
}
1603-
err = _PyMonitoring_SetLocalEvents(self, tool_id, events);
1604-
if (err != 0) {
1605-
return NULL;
1606-
}
1607-
Py_RETURN_NONE;
1608-
}
1609-
16101573

16111574
/******************
16121575
* "extra" frame eval info (see PEP 523)
@@ -2450,6 +2413,48 @@ code__varname_from_oparg_impl(PyCodeObject *self, int oparg)
24502413
return Py_NewRef(name);
24512414
}
24522415

2416+
2417+
/*[clinic input]
2418+
code.__get_local_events__ -> int
2419+
2420+
tool: int
2421+
2422+
[clinic start generated code]*/
2423+
2424+
static int
2425+
code___get_local_events___impl(PyCodeObject *self, int tool)
2426+
/*[clinic end generated code: output=e66c1af8a8c6c2aa input=660474646897971f]*/
2427+
{
2428+
_PyMonitoringEventSet events;
2429+
int err = _PyMonitoring_GetLocalEvents((PyObject *)self, tool, &events);
2430+
if (err != 0) {
2431+
return err;
2432+
}
2433+
return events;
2434+
}
2435+
2436+
2437+
/*[clinic input]
2438+
code.__set_local_events__
2439+
2440+
2441+
tool: int
2442+
events: int
2443+
2444+
[clinic start generated code]*/
2445+
2446+
static PyObject *
2447+
code___set_local_events___impl(PyCodeObject *self, int tool, int events)
2448+
/*[clinic end generated code: output=d80a9ef8386753f7 input=68cdcca03494b242]*/
2449+
{
2450+
int err = _PyMonitoring_SetLocalEvents((PyObject *)self, tool, events);
2451+
if (err < 0) {
2452+
return NULL;
2453+
}
2454+
Py_RETURN_NONE;
2455+
}
2456+
2457+
24532458
/* XXX code objects need to participate in GC? */
24542459

24552460
static struct PyMethodDef code_methods[] = {
@@ -2462,8 +2467,8 @@ static struct PyMethodDef code_methods[] = {
24622467
{"__replace__", _PyCFunction_CAST(code_replace), METH_FASTCALL|METH_KEYWORDS,
24632468
PyDoc_STR("__replace__($self, /, **changes)\n--\n\nThe same as replace().")},
24642469
{"co_offset_to_position", code_offset_to_position, METH_O},
2465-
{"__get_local_events__", code_get_local_events, METH_O},
2466-
{"__set_local_events__", _PyCFunction_CAST(code_set_local_events), METH_FASTCALL},
2470+
CODE___GET_LOCAL_EVENTS___METHODDEF
2471+
CODE___SET_LOCAL_EVENTS___METHODDEF
24672472
{NULL, NULL} /* sentinel */
24682473
};
24692474

0 commit comments

Comments
 (0)