mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
Add more C API tests (GH-112522)
Add tests for PyObject_Str(), PyObject_Repr(), PyObject_ASCII() and PyObject_Bytes().
This commit is contained in:
parent
f9e6ce0395
commit
e0449b9a7f
2 changed files with 119 additions and 0 deletions
|
|
@ -2,6 +2,34 @@
|
|||
#include "util.h"
|
||||
|
||||
|
||||
static PyObject *
|
||||
object_repr(PyObject *self, PyObject *arg)
|
||||
{
|
||||
NULLABLE(arg);
|
||||
return PyObject_Repr(arg);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
object_ascii(PyObject *self, PyObject *arg)
|
||||
{
|
||||
NULLABLE(arg);
|
||||
return PyObject_ASCII(arg);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
object_str(PyObject *self, PyObject *arg)
|
||||
{
|
||||
NULLABLE(arg);
|
||||
return PyObject_Str(arg);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
object_bytes(PyObject *self, PyObject *arg)
|
||||
{
|
||||
NULLABLE(arg);
|
||||
return PyObject_Bytes(arg);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
object_getattr(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
|
@ -616,6 +644,11 @@ sequence_tuple(PyObject *self, PyObject *obj)
|
|||
|
||||
|
||||
static PyMethodDef test_methods[] = {
|
||||
{"object_repr", object_repr, METH_O},
|
||||
{"object_ascii", object_ascii, METH_O},
|
||||
{"object_str", object_str, METH_O},
|
||||
{"object_bytes", object_bytes, METH_O},
|
||||
|
||||
{"object_getattr", object_getattr, METH_VARARGS},
|
||||
{"object_getattrstring", object_getattrstring, METH_VARARGS},
|
||||
{"object_getoptionalattr", object_getoptionalattr, METH_VARARGS},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue