Add the 'bool' type and its values 'False' and 'True', as described in
PEP 285. Everything described in the PEP is here, and there is even
some documentation. I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison. I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.
Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index f4cf0df..b720ae5 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1429,7 +1429,7 @@
return NULL;
}
ok = (mp->ma_lookup)(mp, key, hash)->me_value != NULL;
- return PyInt_FromLong(ok);
+ return PyBool_FromLong(ok);
}
static PyObject *
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 3179574..3e0b85e 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -1444,7 +1444,7 @@
static char close_doc[] =
"close() -> None or (perhaps) an integer. Close the file.\n"
"\n"
-"Sets data attribute .closed to true. A closed file cannot be used for\n"
+"Sets data attribute .closed to True. A closed file cannot be used for\n"
"further I/O operations. close() may be called more than once without\n"
"error. Some kinds of file objects (for example, opened by popen())\n"
"may return an exit status upon closing.";
@@ -1488,11 +1488,11 @@
static PyObject *
get_closed(PyFileObject *f, void *closure)
{
- return PyInt_FromLong((long)(f->f_fp == 0));
+ return PyBool_FromLong((long)(f->f_fp == 0));
}
static PyGetSetDef file_getsetlist[] = {
- {"closed", (getter)get_closed, NULL, "flag set if the file is closed"},
+ {"closed", (getter)get_closed, NULL, "True if the file is closed"},
{0},
};
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 6c8bdbe..5886209 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -10,18 +10,6 @@
return LONG_MAX; /* To initialize sys.maxint */
}
-/* Standard Booleans */
-
-PyIntObject _Py_ZeroStruct = {
- PyObject_HEAD_INIT(&PyInt_Type)
- 0
-};
-
-PyIntObject _Py_TrueStruct = {
- PyObject_HEAD_INIT(&PyInt_Type)
- 1
-};
-
/* Return 1 if exception raised, 0 if caller should retry using longs */
static int
err_ovf(char *msg)
diff --git a/Objects/object.c b/Objects/object.c
index 396f734..6cb5747 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1763,6 +1763,9 @@
if (PyType_Ready(&PyType_Type) < 0)
Py_FatalError("Can't initialize 'type'");
+ if (PyType_Ready(&PyBool_Type) < 0)
+ Py_FatalError("Can't initialize 'bool'");
+
if (PyType_Ready(&PyList_Type) < 0)
Py_FatalError("Can't initialize 'list'");
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 144c5b0..2a63cfe 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -2000,9 +2000,9 @@
static char startswith__doc__[] =
-"S.startswith(prefix[, start[, end]]) -> int\n\
+"S.startswith(prefix[, start[, end]]) -> bool\n\
\n\
-Return 1 if S starts with the specified prefix, otherwise return 0. With\n\
+Return True if S starts with the specified prefix, False otherwise. With\n\
optional start, test S beginning at that position. With optional end, stop\n\
comparing S at that position.";
@@ -2032,7 +2032,7 @@
if (rc == -1)
return NULL;
else
- return PyInt_FromLong((long) rc);
+ return PyBool_FromLong((long) rc);
}
#endif
else if (PyObject_AsCharBuffer(subobj, &prefix, &plen))
@@ -2043,25 +2043,25 @@
* the empty string.
*/
if (start < 0 || start+plen > len)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
if (!memcmp(str+start, prefix, plen)) {
/* did the match end after the specified end? */
if (end < 0)
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
else if (end - start < plen)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
else
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
- else return PyInt_FromLong(0);
+ else return PyBool_FromLong(0);
}
static char endswith__doc__[] =
-"S.endswith(suffix[, start[, end]]) -> int\n\
+"S.endswith(suffix[, start[, end]]) -> bool\n\
\n\
-Return 1 if S ends with the specified suffix, otherwise return 0. With\n\
+Return True if S ends with the specified suffix, False otherwise. With\n\
optional start, test S beginning at that position. With optional end, stop\n\
comparing S at that position.";
@@ -2092,21 +2092,21 @@
if (rc == -1)
return NULL;
else
- return PyInt_FromLong((long) rc);
+ return PyBool_FromLong((long) rc);
}
#endif
else if (PyObject_AsCharBuffer(subobj, &suffix, &slen))
return NULL;
if (start < 0 || start > len || slen > len)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
upper = (end >= 0 && end <= len) ? end : len;
lower = (upper - slen) > start ? (upper - slen) : start;
if (upper-lower >= slen && !memcmp(str+lower, suffix, slen))
- return PyInt_FromLong(1);
- else return PyInt_FromLong(0);
+ return PyBool_FromLong(1);
+ else return PyBool_FromLong(0);
}
@@ -2311,10 +2311,10 @@
}
static char isspace__doc__[] =
-"S.isspace() -> int\n"
+"S.isspace() -> bool\n"
"\n"
-"Return 1 if there are only whitespace characters in S,\n"
-"0 otherwise.";
+"Return True if there are only whitespace characters in S,\n"
+"False otherwise.";
static PyObject*
string_isspace(PyStringObject *self)
@@ -2326,26 +2326,26 @@
/* Shortcut for single character strings */
if (PyString_GET_SIZE(self) == 1 &&
isspace(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyString_GET_SIZE(self);
for (; p < e; p++) {
if (!isspace(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char isalpha__doc__[] =
-"S.isalpha() -> int\n\
+"S.isalpha() -> bool\n\
\n\
-Return 1 if all characters in S are alphabetic\n\
-and there is at least one character in S, 0 otherwise.";
+Return True if all characters in S are alphabetic\n\
+and there is at least one character in S, False otherwise.";
static PyObject*
string_isalpha(PyStringObject *self)
@@ -2357,26 +2357,26 @@
/* Shortcut for single character strings */
if (PyString_GET_SIZE(self) == 1 &&
isalpha(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyString_GET_SIZE(self);
for (; p < e; p++) {
if (!isalpha(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char isalnum__doc__[] =
-"S.isalnum() -> int\n\
+"S.isalnum() -> bool\n\
\n\
-Return 1 if all characters in S are alphanumeric\n\
-and there is at least one character in S, 0 otherwise.";
+Return True if all characters in S are alphanumeric\n\
+and there is at least one character in S, False otherwise.";
static PyObject*
string_isalnum(PyStringObject *self)
@@ -2388,26 +2388,26 @@
/* Shortcut for single character strings */
if (PyString_GET_SIZE(self) == 1 &&
isalnum(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyString_GET_SIZE(self);
for (; p < e; p++) {
if (!isalnum(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char isdigit__doc__[] =
-"S.isdigit() -> int\n\
+"S.isdigit() -> bool\n\
\n\
-Return 1 if there are only digit characters in S,\n\
-0 otherwise.";
+Return True if there are only digit characters in S,\n\
+False otherwise.";
static PyObject*
string_isdigit(PyStringObject *self)
@@ -2419,26 +2419,26 @@
/* Shortcut for single character strings */
if (PyString_GET_SIZE(self) == 1 &&
isdigit(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyString_GET_SIZE(self);
for (; p < e; p++) {
if (!isdigit(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char islower__doc__[] =
-"S.islower() -> int\n\
+"S.islower() -> bool\n\
\n\
-Return 1 if all cased characters in S are lowercase and there is\n\
-at least one cased character in S, 0 otherwise.";
+Return True if all cased characters in S are lowercase and there is\n\
+at least one cased character in S, False otherwise.";
static PyObject*
string_islower(PyStringObject *self)
@@ -2450,29 +2450,29 @@
/* Shortcut for single character strings */
if (PyString_GET_SIZE(self) == 1)
- return PyInt_FromLong(islower(*p) != 0);
+ return PyBool_FromLong(islower(*p) != 0);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyString_GET_SIZE(self);
cased = 0;
for (; p < e; p++) {
if (isupper(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
else if (!cased && islower(*p))
cased = 1;
}
- return PyInt_FromLong(cased);
+ return PyBool_FromLong(cased);
}
static char isupper__doc__[] =
-"S.isupper() -> int\n\
+"S.isupper() -> bool\n\
\n\
-Return 1 if all cased characters in S are uppercase and there is\n\
-at least one cased character in S, 0 otherwise.";
+Return True if all cased characters in S are uppercase and there is\n\
+at least one cased character in S, False otherwise.";
static PyObject*
string_isupper(PyStringObject *self)
@@ -2484,30 +2484,30 @@
/* Shortcut for single character strings */
if (PyString_GET_SIZE(self) == 1)
- return PyInt_FromLong(isupper(*p) != 0);
+ return PyBool_FromLong(isupper(*p) != 0);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyString_GET_SIZE(self);
cased = 0;
for (; p < e; p++) {
if (islower(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
else if (!cased && isupper(*p))
cased = 1;
}
- return PyInt_FromLong(cased);
+ return PyBool_FromLong(cased);
}
static char istitle__doc__[] =
-"S.istitle() -> int\n\
+"S.istitle() -> bool\n\
\n\
-Return 1 if S is a titlecased string, i.e. uppercase characters\n\
+Return True if S is a titlecased string, i.e. uppercase characters\n\
may only follow uncased characters and lowercase characters only cased\n\
-ones. Return 0 otherwise.";
+ones. Return False otherwise.";
static PyObject*
string_istitle(PyStringObject *self, PyObject *uncased)
@@ -2519,11 +2519,11 @@
/* Shortcut for single character strings */
if (PyString_GET_SIZE(self) == 1)
- return PyInt_FromLong(isupper(*p) != 0);
+ return PyBool_FromLong(isupper(*p) != 0);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyString_GET_SIZE(self);
cased = 0;
@@ -2533,20 +2533,20 @@
if (isupper(ch)) {
if (previous_is_cased)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
previous_is_cased = 1;
cased = 1;
}
else if (islower(ch)) {
if (!previous_is_cased)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
previous_is_cased = 1;
cased = 1;
}
else
previous_is_cased = 0;
}
- return PyInt_FromLong(cased);
+ return PyBool_FromLong(cased);
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 96cc5f4..a49ff70 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -4109,10 +4109,10 @@
}
static char islower__doc__[] =
-"S.islower() -> int\n\
+"S.islower() -> bool\n\
\n\
-Return 1 if all cased characters in S are lowercase and there is\n\
-at least one cased character in S, 0 otherwise.";
+Return True if all cased characters in S are lowercase and there is\n\
+at least one cased character in S, False otherwise.";
static PyObject*
unicode_islower(PyUnicodeObject *self)
@@ -4123,11 +4123,11 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1)
- return PyInt_FromLong(Py_UNICODE_ISLOWER(*p) != 0);
+ return PyBool_FromLong(Py_UNICODE_ISLOWER(*p));
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
cased = 0;
@@ -4135,18 +4135,18 @@
register const Py_UNICODE ch = *p;
if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
else if (!cased && Py_UNICODE_ISLOWER(ch))
cased = 1;
}
- return PyInt_FromLong(cased);
+ return PyBool_FromLong(cased);
}
static char isupper__doc__[] =
-"S.isupper() -> int\n\
+"S.isupper() -> bool\n\
\n\
-Return 1 if all cased characters in S are uppercase and there is\n\
-at least one cased character in S, 0 otherwise.";
+Return True if all cased characters in S are uppercase and there is\n\
+at least one cased character in S, False otherwise.";
static PyObject*
unicode_isupper(PyUnicodeObject *self)
@@ -4157,11 +4157,11 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1)
- return PyInt_FromLong(Py_UNICODE_ISUPPER(*p) != 0);
+ return PyBool_FromLong(Py_UNICODE_ISUPPER(*p) != 0);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
cased = 0;
@@ -4169,19 +4169,19 @@
register const Py_UNICODE ch = *p;
if (Py_UNICODE_ISLOWER(ch) || Py_UNICODE_ISTITLE(ch))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
else if (!cased && Py_UNICODE_ISUPPER(ch))
cased = 1;
}
- return PyInt_FromLong(cased);
+ return PyBool_FromLong(cased);
}
static char istitle__doc__[] =
-"S.istitle() -> int\n\
+"S.istitle() -> bool\n\
\n\
-Return 1 if S is a titlecased string, i.e. upper- and titlecase characters\n\
-may only follow uncased characters and lowercase characters only cased\n\
-ones. Return 0 otherwise.";
+Return True if S is a titlecased string, i.e. upper- and titlecase\n\
+characters may only follow uncased characters and lowercase characters\n\
+only cased ones. Return False otherwise.";
static PyObject*
unicode_istitle(PyUnicodeObject *self)
@@ -4192,12 +4192,12 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1)
- return PyInt_FromLong((Py_UNICODE_ISTITLE(*p) != 0) ||
- (Py_UNICODE_ISUPPER(*p) != 0));
+ return PyBool_FromLong((Py_UNICODE_ISTITLE(*p) != 0) ||
+ (Py_UNICODE_ISUPPER(*p) != 0));
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
cased = 0;
@@ -4207,27 +4207,27 @@
if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) {
if (previous_is_cased)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
previous_is_cased = 1;
cased = 1;
}
else if (Py_UNICODE_ISLOWER(ch)) {
if (!previous_is_cased)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
previous_is_cased = 1;
cased = 1;
}
else
previous_is_cased = 0;
}
- return PyInt_FromLong(cased);
+ return PyBool_FromLong(cased);
}
static char isspace__doc__[] =
-"S.isspace() -> int\n\
+"S.isspace() -> bool\n\
\n\
-Return 1 if there are only whitespace characters in S,\n\
-0 otherwise.";
+Return True if there are only whitespace characters in S,\n\
+False otherwise.";
static PyObject*
unicode_isspace(PyUnicodeObject *self)
@@ -4238,25 +4238,25 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1 &&
Py_UNICODE_ISSPACE(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
for (; p < e; p++) {
if (!Py_UNICODE_ISSPACE(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char isalpha__doc__[] =
-"S.isalpha() -> int\n\
+"S.isalpha() -> bool\n\
\n\
-Return 1 if all characters in S are alphabetic\n\
-and there is at least one character in S, 0 otherwise.";
+Return True if all characters in S are alphabetic\n\
+and there is at least one character in S, False otherwise.";
static PyObject*
unicode_isalpha(PyUnicodeObject *self)
@@ -4267,25 +4267,25 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1 &&
Py_UNICODE_ISALPHA(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
for (; p < e; p++) {
if (!Py_UNICODE_ISALPHA(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char isalnum__doc__[] =
-"S.isalnum() -> int\n\
+"S.isalnum() -> bool\n\
\n\
-Return 1 if all characters in S are alphanumeric\n\
-and there is at least one character in S, 0 otherwise.";
+Return True if all characters in S are alphanumeric\n\
+and there is at least one character in S, False otherwise.";
static PyObject*
unicode_isalnum(PyUnicodeObject *self)
@@ -4296,25 +4296,25 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1 &&
Py_UNICODE_ISALNUM(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
for (; p < e; p++) {
if (!Py_UNICODE_ISALNUM(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char isdecimal__doc__[] =
-"S.isdecimal() -> int\n\
+"S.isdecimal() -> bool\n\
\n\
-Return 1 if there are only decimal characters in S,\n\
-0 otherwise.";
+Return True if there are only decimal characters in S,\n\
+False otherwise.";
static PyObject*
unicode_isdecimal(PyUnicodeObject *self)
@@ -4325,25 +4325,25 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1 &&
Py_UNICODE_ISDECIMAL(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
for (; p < e; p++) {
if (!Py_UNICODE_ISDECIMAL(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char isdigit__doc__[] =
-"S.isdigit() -> int\n\
+"S.isdigit() -> bool\n\
\n\
-Return 1 if there are only digit characters in S,\n\
-0 otherwise.";
+Return True if there are only digit characters in S,\n\
+False otherwise.";
static PyObject*
unicode_isdigit(PyUnicodeObject *self)
@@ -4354,25 +4354,25 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1 &&
Py_UNICODE_ISDIGIT(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
for (; p < e; p++) {
if (!Py_UNICODE_ISDIGIT(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char isnumeric__doc__[] =
-"S.isnumeric() -> int\n\
+"S.isnumeric() -> bool\n\
\n\
-Return 1 if there are only numeric characters in S,\n\
-0 otherwise.";
+Return True if there are only numeric characters in S,\n\
+False otherwise.";
static PyObject*
unicode_isnumeric(PyUnicodeObject *self)
@@ -4383,18 +4383,18 @@
/* Shortcut for single character strings */
if (PyUnicode_GET_SIZE(self) == 1 &&
Py_UNICODE_ISNUMERIC(*p))
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
/* Special case for empty strings */
if (PyString_GET_SIZE(self) == 0)
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
e = p + PyUnicode_GET_SIZE(self);
for (; p < e; p++) {
if (!Py_UNICODE_ISNUMERIC(*p))
- return PyInt_FromLong(0);
+ return PyBool_FromLong(0);
}
- return PyInt_FromLong(1);
+ return PyBool_FromLong(1);
}
static char join__doc__[] =
@@ -4862,9 +4862,9 @@
#endif
static char startswith__doc__[] =
-"S.startswith(prefix[, start[, end]]) -> int\n\
+"S.startswith(prefix[, start[, end]]) -> bool\n\
\n\
-Return 1 if S starts with the specified prefix, otherwise return 0. With\n\
+Return True if S starts with the specified prefix, False otherwise. With\n\
optional start, test S beginning at that position. With optional end, stop\n\
comparing S at that position.";
@@ -4885,7 +4885,7 @@
if (substring == NULL)
return NULL;
- result = PyInt_FromLong(tailmatch(self, substring, start, end, -1));
+ result = PyBool_FromLong(tailmatch(self, substring, start, end, -1));
Py_DECREF(substring);
return result;
@@ -4893,9 +4893,9 @@
static char endswith__doc__[] =
-"S.endswith(suffix[, start[, end]]) -> int\n\
+"S.endswith(suffix[, start[, end]]) -> bool\n\
\n\
-Return 1 if S ends with the specified suffix, otherwise return 0. With\n\
+Return True if S ends with the specified suffix, False otherwise. With\n\
optional start, test S beginning at that position. With optional end, stop\n\
comparing S at that position.";
@@ -4916,7 +4916,7 @@
if (substring == NULL)
return NULL;
- result = PyInt_FromLong(tailmatch(self, substring, start, end, +1));
+ result = PyBool_FromLong(tailmatch(self, substring, start, end, +1));
Py_DECREF(substring);
return result;