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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-103131: Convert sys.set_asyncgen_hooks
to AC
#103132
Changes from 1 commit
e3f5e71
c9a71d9
2f0839f
23d4e95
9a5b800
c008650
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Convert :func:`sys.getsizeof` and :func:`sys.set_asyncgen_hooks` | ||
to argument clinic. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1291,19 +1291,20 @@ static PyStructSequence_Desc asyncgen_hooks_desc = { | |||||
2 | ||||||
}; | ||||||
|
||||||
static PyObject * | ||||||
sys_set_asyncgen_hooks(PyObject *self, PyObject *args, PyObject *kw) | ||||||
{ | ||||||
static char *keywords[] = {"firstiter", "finalizer", NULL}; | ||||||
PyObject *firstiter = NULL; | ||||||
PyObject *finalizer = NULL; | ||||||
/*[clinic input] | ||||||
sys.set_asyncgen_hooks | ||||||
|
||||||
if (!PyArg_ParseTupleAndKeywords( | ||||||
args, kw, "|OO", keywords, | ||||||
&firstiter, &finalizer)) { | ||||||
return NULL; | ||||||
} | ||||||
firstiter: object = NULL | ||||||
finalizer: object = NULL | ||||||
|
||||||
Set a finalizer for async generators objects. | ||||||
[clinic start generated code]*/ | ||||||
|
||||||
static PyObject * | ||||||
sys_set_asyncgen_hooks_impl(PyObject *module, PyObject *firstiter, | ||||||
PyObject *finalizer) | ||||||
/*[clinic end generated code: output=6fe3b2dd3f9a9db5 input=ef6a1e96361234be]*/ | ||||||
{ | ||||||
if (finalizer && finalizer != Py_None) { | ||||||
if (!PyCallable_Check(finalizer)) { | ||||||
PyErr_Format(PyExc_TypeError, | ||||||
|
@@ -1337,12 +1338,6 @@ sys_set_asyncgen_hooks(PyObject *self, PyObject *args, PyObject *kw) | |||||
Py_RETURN_NONE; | ||||||
} | ||||||
|
||||||
PyDoc_STRVAR(set_asyncgen_hooks_doc, | ||||||
"set_asyncgen_hooks(* [, firstiter] [, finalizer])\n\ | ||||||
\n\ | ||||||
Set a finalizer for async generators objects." | ||||||
); | ||||||
|
||||||
/*[clinic input] | ||||||
sys.get_asyncgen_hooks | ||||||
|
||||||
|
@@ -1792,20 +1787,23 @@ _PySys_GetSizeOf(PyObject *o) | |||||
return (size_t)size + _PyType_PreHeaderSize(Py_TYPE(o)); | ||||||
} | ||||||
|
||||||
/*[clinic input] | ||||||
sys.getsizeof | ||||||
|
||||||
object: object | ||||||
default as dflt: object = NULL | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to use a longer name rather than a shorter one:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would make the diff unnecessary bigger. IMO, it is better to align with the current naming. |
||||||
|
||||||
Return the size of object in bytes. | ||||||
[clinic start generated code]*/ | ||||||
|
||||||
static PyObject * | ||||||
sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds) | ||||||
sys_getsizeof_impl(PyObject *module, PyObject *object, PyObject *dflt) | ||||||
/*[clinic end generated code: output=3f326a2f59e30975 input=7712d53f10145836]*/ | ||||||
{ | ||||||
static char *kwlist[] = {"object", "default", 0}; | ||||||
size_t size; | ||||||
PyObject *o, *dflt = NULL; | ||||||
PyThreadState *tstate = _PyThreadState_GET(); | ||||||
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:getsizeof", | ||||||
kwlist, &o, &dflt)) { | ||||||
return NULL; | ||||||
} | ||||||
|
||||||
size = _PySys_GetSizeOf(o); | ||||||
size = _PySys_GetSizeOf(object); | ||||||
|
||||||
if (size == (size_t)-1 && _PyErr_Occurred(tstate)) { | ||||||
/* Has a default value been given */ | ||||||
|
@@ -1820,11 +1818,6 @@ sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds) | |||||
return PyLong_FromSize_t(size); | ||||||
} | ||||||
|
||||||
PyDoc_STRVAR(getsizeof_doc, | ||||||
"getsizeof(object [, default]) -> int\n\ | ||||||
\n\ | ||||||
Return the size of object in bytes."); | ||||||
|
||||||
/*[clinic input] | ||||||
sys.getrefcount -> Py_ssize_t | ||||||
|
||||||
|
@@ -2251,8 +2244,7 @@ static PyMethodDef sys_methods[] = { | |||||
SYS_GETTOTALREFCOUNT_METHODDEF | ||||||
SYS_GETREFCOUNT_METHODDEF | ||||||
SYS_GETRECURSIONLIMIT_METHODDEF | ||||||
{"getsizeof", _PyCFunction_CAST(sys_getsizeof), | ||||||
METH_VARARGS | METH_KEYWORDS, getsizeof_doc}, | ||||||
SYS_GETSIZEOF_METHODDEF | ||||||
SYS__GETFRAME_METHODDEF | ||||||
SYS__GETFRAMEMODULENAME_METHODDEF | ||||||
SYS_GETWINDOWSVERSION_METHODDEF | ||||||
|
@@ -2274,8 +2266,7 @@ static PyMethodDef sys_methods[] = { | |||||
SYS__DEBUGMALLOCSTATS_METHODDEF | ||||||
SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF | ||||||
SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF | ||||||
{"set_asyncgen_hooks", _PyCFunction_CAST(sys_set_asyncgen_hooks), | ||||||
METH_VARARGS | METH_KEYWORDS, set_asyncgen_hooks_doc}, | ||||||
SYS_SET_ASYNCGEN_HOOKS_METHODDEF | ||||||
SYS_GET_ASYNCGEN_HOOKS_METHODDEF | ||||||
SYS_GETANDROIDAPILEVEL_METHODDEF | ||||||
SYS_ACTIVATE_STACK_TRAMPOLINE_METHODDEF | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an internal refactoring. Such changes usually are not reflected in the NEWS file.