diff options
author | jdemeyer <jdemeyer@cage.ugent.be> | 2018-10-19 23:50:06 +0200 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-10-19 23:50:06 +0200 |
commit | 5a30620e68ebb911eef4d583de3776d782148637 (patch) | |
tree | e33bb26ccf2ab594a27b3c785e23354580de457c /Modules/_testcapimodule.c | |
parent | b2e2025941f6a4fdb716bd141d31acf720353d21 (diff) | |
download | cpython-git-5a30620e68ebb911eef4d583de3776d782148637.tar.gz |
bpo-25750: Add test on bad descriptor __get__() (GH-9084)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index add642f223..4381e93ca9 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4550,6 +4550,28 @@ new_hamt(PyObject *self, PyObject *args) } +/* def bad_get(self, obj, cls): + cls() + return repr(self) +*/ +static PyObject* +bad_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + if (nargs != 3) { + PyErr_SetString(PyExc_TypeError, "bad_get requires exactly 3 arguments"); + return NULL; + } + + PyObject *res = PyObject_CallObject(args[2], NULL); + if (res == NULL) { + return NULL; + } + Py_DECREF(res); + + return PyObject_Repr(args[0]); +} + + static PyObject * encode_locale_ex(PyObject *self, PyObject *args) { @@ -5017,6 +5039,7 @@ static PyMethodDef TestMethods[] = { {"get_mapping_items", get_mapping_items, METH_O}, {"test_pythread_tss_key_state", test_pythread_tss_key_state, METH_VARARGS}, {"hamt", new_hamt, METH_NOARGS}, + {"bad_get", bad_get, METH_FASTCALL}, {"EncodeLocaleEx", encode_locale_ex, METH_VARARGS}, {"DecodeLocaleEx", decode_locale_ex, METH_VARARGS}, {"get_coreconfig", get_coreconfig, METH_NOARGS}, |