@@ -2376,16 +2376,22 @@ test_long_numbits(PyObject *self, PyObject *Py_UNUSED(ignored))
23762376 Py_RETURN_NONE ;
23772377}
23782378
2379- /* Example passing NULLs to PyObject_Str(NULL). */
2379+ static PyObject *
2380+ pyobject_repr_from_null (PyObject * self , PyObject * Py_UNUSED (ignored ))
2381+ {
2382+ return PyObject_Repr (NULL );
2383+ }
23802384
23812385static PyObject *
2382- test_null_strings (PyObject * self , PyObject * Py_UNUSED (ignored ))
2386+ pyobject_str_from_null (PyObject * self , PyObject * Py_UNUSED (ignored ))
23832387{
2384- PyObject * o1 = PyObject_Str (NULL ), * o2 = PyObject_Str (NULL );
2385- PyObject * tuple = PyTuple_Pack (2 , o1 , o2 );
2386- Py_XDECREF (o1 );
2387- Py_XDECREF (o2 );
2388- return tuple ;
2388+ return PyObject_Str (NULL );
2389+ }
2390+
2391+ static PyObject *
2392+ pyobject_bytes_from_null (PyObject * self , PyObject * Py_UNUSED (ignored ))
2393+ {
2394+ return PyObject_Bytes (NULL );
23892395}
23902396
23912397static PyObject *
@@ -5702,7 +5708,9 @@ static PyMethodDef TestMethods[] = {
57025708 {"test_k_code" , test_k_code , METH_NOARGS },
57035709 {"test_empty_argparse" , test_empty_argparse , METH_NOARGS },
57045710 {"parse_tuple_and_keywords" , parse_tuple_and_keywords , METH_VARARGS },
5705- {"test_null_strings" , test_null_strings , METH_NOARGS },
5711+ {"pyobject_repr_from_null" , pyobject_repr_from_null , METH_NOARGS },
5712+ {"pyobject_str_from_null" , pyobject_str_from_null , METH_NOARGS },
5713+ {"pyobject_bytes_from_null" , pyobject_bytes_from_null , METH_NOARGS },
57065714 {"test_string_from_format" , (PyCFunction )test_string_from_format , METH_NOARGS },
57075715 {"test_with_docstring" , test_with_docstring , METH_NOARGS ,
57085716 PyDoc_STR ("This is a pretty normal docstring." )},
0 commit comments