Skip to content

Commit 402967d

Browse files
committed
Move tests to _testcapi/abstract.c
1 parent bb6777b commit 402967d

2 files changed

Lines changed: 37 additions & 37 deletions

File tree

Modules/_testcapi/abstract.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,41 @@ sequence_fast_get_item(PyObject *self, PyObject *args)
178178
}
179179

180180

181+
static PyObject *
182+
object_setattr_null_exc(PyObject *self, PyObject *args)
183+
{
184+
PyObject *obj, *name;
185+
if (!PyArg_ParseTuple(args, "OO", &obj, &name)) {
186+
return NULL;
187+
}
188+
189+
PyErr_SetString(PyExc_ValueError, "error");
190+
if (PyObject_SetAttr(obj, name, NULL) < 0) {
191+
return NULL;
192+
}
193+
assert(PyErr_Occurred());
194+
return NULL;
195+
}
196+
197+
198+
static PyObject *
199+
object_setattrstring_null_exc(PyObject *self, PyObject *args)
200+
{
201+
PyObject *obj;
202+
const char *name;
203+
if (!PyArg_ParseTuple(args, "Os", &obj, &name)) {
204+
return NULL;
205+
}
206+
207+
PyErr_SetString(PyExc_ValueError, "error");
208+
if (PyObject_SetAttrString(obj, name, NULL) < 0) {
209+
return NULL;
210+
}
211+
assert(PyErr_Occurred());
212+
return NULL;
213+
}
214+
215+
181216
static PyMethodDef test_methods[] = {
182217
{"object_getoptionalattr", object_getoptionalattr, METH_VARARGS},
183218
{"object_getoptionalattrstring", object_getoptionalattrstring, METH_VARARGS},
@@ -191,6 +226,8 @@ static PyMethodDef test_methods[] = {
191226

192227
{"sequence_fast_get_size", sequence_fast_get_size, METH_O},
193228
{"sequence_fast_get_item", sequence_fast_get_item, METH_VARARGS},
229+
{"object_setattr_null_exc", object_setattr_null_exc, METH_VARARGS},
230+
{"object_setattrstring_null_exc", object_setattrstring_null_exc, METH_VARARGS},
194231
{NULL},
195232
};
196233

Modules/_testcapi/object.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -485,41 +485,6 @@ is_uniquely_referenced(PyObject *self, PyObject *op)
485485
}
486486

487487

488-
static PyObject *
489-
object_setattr_null_exc(PyObject *self, PyObject *args)
490-
{
491-
PyObject *obj, *name;
492-
if (!PyArg_ParseTuple(args, "OO", &obj, &name)) {
493-
return NULL;
494-
}
495-
496-
PyErr_SetString(PyExc_ValueError, "error");
497-
if (PyObject_SetAttr(obj, name, NULL) < 0) {
498-
return NULL;
499-
}
500-
assert(PyErr_Occurred());
501-
return NULL;
502-
}
503-
504-
505-
static PyObject *
506-
object_setattrstring_null_exc(PyObject *self, PyObject *args)
507-
{
508-
PyObject *obj;
509-
const char *name;
510-
if (!PyArg_ParseTuple(args, "Os", &obj, &name)) {
511-
return NULL;
512-
}
513-
514-
PyErr_SetString(PyExc_ValueError, "error");
515-
if (PyObject_SetAttrString(obj, name, NULL) < 0) {
516-
return NULL;
517-
}
518-
assert(PyErr_Occurred());
519-
return NULL;
520-
}
521-
522-
523488
static PyMethodDef test_methods[] = {
524489
{"call_pyobject_print", call_pyobject_print, METH_VARARGS},
525490
{"pyobject_print_null", pyobject_print_null, METH_VARARGS},
@@ -546,8 +511,6 @@ static PyMethodDef test_methods[] = {
546511
{"test_py_is_funcs", test_py_is_funcs, METH_NOARGS},
547512
{"clear_managed_dict", clear_managed_dict, METH_O, NULL},
548513
{"is_uniquely_referenced", is_uniquely_referenced, METH_O},
549-
{"object_setattr_null_exc", object_setattr_null_exc, METH_VARARGS},
550-
{"object_setattrstring_null_exc", object_setattrstring_null_exc, METH_VARARGS},
551514
{NULL},
552515
};
553516

0 commit comments

Comments
 (0)