Issue #28526: Use PyUnicode_AsEncodedString() instead of PyUnicode_AsEncodedObject() in _curese to ensure that the result is a bytes object.