Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ struct _Py_global_strings {
} literals;

struct {
STRUCT_FOR_ID(False)
STRUCT_FOR_ID(Py_Repr)
STRUCT_FOR_ID(TextIOWrapper)
STRUCT_FOR_ID(True)
STRUCT_FOR_ID(WarningMessage)
STRUCT_FOR_ID(_)
STRUCT_FOR_ID(__IOBase_closed)
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_runtime_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,10 @@ extern "C" {
INIT_STR(percent, "%"), \
}, \
.identifiers = { \
INIT_ID(False), \
INIT_ID(Py_Repr), \
INIT_ID(TextIOWrapper), \
INIT_ID(True), \
INIT_ID(WarningMessage), \
INIT_ID(_), \
INIT_ID(__IOBase_closed), \
Expand Down
20 changes: 7 additions & 13 deletions Objects/boolobject.c
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
/* Boolean type, a subtype of int */

#include "Python.h"
#include "pycore_runtime.h" // _Py_ID()
#include "pycore_pyerrors.h" // _Py_FatalRefcountError()

/* 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)
{
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);
return s;
if (self == Py_True) {
return &_Py_ID(True);
}
else {
return &_Py_ID(False);
}
}

/* Function to return a bool from a C long */
Expand Down
2 changes: 0 additions & 2 deletions Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ Objects/sliceobject.c - _Py_EllipsisObject -
# cached - initialized once

# manually cached PyUnicodeObject
Objects/boolobject.c - false_str -
Objects/boolobject.c - true_str -
Objects/classobject.c method_get_doc docstr -
Objects/classobject.c instancemethod_get_doc docstr -
Objects/codeobject.c PyCode_NewEmpty emptystring -
Expand Down