Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions Objects/boolobject.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,22 +4,25 @@
#include "longintrepr.h"

/* We define bool_repr to return "False" or "True" */

static PyObject *false_str = NULL;
static PyObject *true_str = NULL;

static PyObject *
bool_repr(PyObject *self)
{
_Py_IDENTIFIER(True);
_Py_IDENTIFIER(False);

PyObject *s;

if (self == Py_True)
s = true_str ? true_str :
(true_str = PyUnicode_InternFromString("True"));
else
s = false_str ? false_str :
(false_str = PyUnicode_InternFromString("False"));
Py_XINCREF(s);
{
s = _PyUnicode_FromId(&PyId_True); // borrowed ref
} else{
s = _PyUnicode_FromId(&PyId_False); // borrowed ref
}

if (s != NULL){
return Py_NewRef(s);
}

return s;
}

Expand Down