@@ -2215,16 +2215,22 @@ test_long_numbits(PyObject *self, PyObject *Py_UNUSED(ignored))
2215
2215
Py_RETURN_NONE ;
2216
2216
}
2217
2217
2218
- /* Example passing NULLs to PyObject_Str(NULL). */
2218
+ static PyObject *
2219
+ pyobject_repr_from_null (PyObject * self , PyObject * Py_UNUSED (ignored ))
2220
+ {
2221
+ return PyObject_Repr (NULL );
2222
+ }
2219
2223
2220
2224
static PyObject *
2221
- test_null_strings (PyObject * self , PyObject * Py_UNUSED (ignored ))
2225
+ pyobject_str_from_null (PyObject * self , PyObject * Py_UNUSED (ignored ))
2222
2226
{
2223
- PyObject * o1 = PyObject_Str (NULL ), * o2 = PyObject_Str (NULL );
2224
- PyObject * tuple = PyTuple_Pack (2 , o1 , o2 );
2225
- Py_XDECREF (o1 );
2226
- Py_XDECREF (o2 );
2227
- return tuple ;
2227
+ return PyObject_Str (NULL );
2228
+ }
2229
+
2230
+ static PyObject *
2231
+ pyobject_bytes_from_null (PyObject * self , PyObject * Py_UNUSED (ignored ))
2232
+ {
2233
+ return PyObject_Bytes (NULL );
2228
2234
}
2229
2235
2230
2236
static PyObject *
@@ -5371,7 +5377,9 @@ static PyMethodDef TestMethods[] = {
5371
5377
{"test_k_code" , test_k_code , METH_NOARGS },
5372
5378
{"test_empty_argparse" , test_empty_argparse , METH_NOARGS },
5373
5379
{"parse_tuple_and_keywords" , parse_tuple_and_keywords , METH_VARARGS },
5374
- {"test_null_strings" , test_null_strings , METH_NOARGS },
5380
+ {"pyobject_repr_from_null" , pyobject_repr_from_null , METH_NOARGS },
5381
+ {"pyobject_str_from_null" , pyobject_str_from_null , METH_NOARGS },
5382
+ {"pyobject_bytes_from_null" , pyobject_bytes_from_null , METH_NOARGS },
5375
5383
{"test_string_from_format" , (PyCFunction )test_string_from_format , METH_NOARGS },
5376
5384
{"test_with_docstring" , test_with_docstring , METH_NOARGS ,
5377
5385
PyDoc_STR ("This is a pretty normal docstring." )},
0 commit comments