New GitHub issue #98421 from MonadChains:<br>

<hr>

<pre>
# Bug report

While working on covering `PyObject_Print`, I noticed that I couldn't hit some lines with any test. Specifically, the part that checks the type of the representation of the object returned by `PyObject_Str` or `PyObject_Repr`:
https://github.com/python/cpython/blob/f4ead4874b558efa6379e3a130b0c491fec3acb1/Objects/object.c#L280-L308

As pointed out by @encukou, both aforementioned functions already check and **ensure** that the return type is a Python string:
https://github.com/python/cpython/blob/f4ead4874b558efa6379e3a130b0c491fec3acb1/Objects/object.c#L492-L498
https://github.com/python/cpython/blob/f4ead4874b558efa6379e3a130b0c491fec3acb1/Objects/object.c#L433-L439

So it is possible to simplify the function by excluding the useless checks of types diffent from Python string.


</pre>

<hr>

<a href="https://github.com/python/cpython/issues/98421">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>