Skip to content

Commit 370fd20

Browse files
Use Py_RETURN_FALSE/Py_RETURN_TRUE rather than PyBool_FromLong(0)/PyBool_FromLong(1). (python#567)
1 parent f7eda38 commit 370fd20

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

Objects/unicodeobject.c

+25-25
Original file line numberDiff line numberDiff line change
@@ -11748,14 +11748,14 @@ unicode_islower_impl(PyObject *self)
1174811748

1174911749
/* Special case for empty strings */
1175011750
if (length == 0)
11751-
return PyBool_FromLong(0);
11751+
Py_RETURN_FALSE;
1175211752

1175311753
cased = 0;
1175411754
for (i = 0; i < length; i++) {
1175511755
const Py_UCS4 ch = PyUnicode_READ(kind, data, i);
1175611756

1175711757
if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch))
11758-
return PyBool_FromLong(0);
11758+
Py_RETURN_FALSE;
1175911759
else if (!cased && Py_UNICODE_ISLOWER(ch))
1176011760
cased = 1;
1176111761
}
@@ -11793,14 +11793,14 @@ unicode_isupper_impl(PyObject *self)
1179311793

1179411794
/* Special case for empty strings */
1179511795
if (length == 0)
11796-
return PyBool_FromLong(0);
11796+
Py_RETURN_FALSE;
1179711797

1179811798
cased = 0;
1179911799
for (i = 0; i < length; i++) {
1180011800
const Py_UCS4 ch = PyUnicode_READ(kind, data, i);
1180111801

1180211802
if (Py_UNICODE_ISLOWER(ch) || Py_UNICODE_ISTITLE(ch))
11803-
return PyBool_FromLong(0);
11803+
Py_RETURN_FALSE;
1180411804
else if (!cased && Py_UNICODE_ISUPPER(ch))
1180511805
cased = 1;
1180611806
}
@@ -11840,7 +11840,7 @@ unicode_istitle_impl(PyObject *self)
1184011840

1184111841
/* Special case for empty strings */
1184211842
if (length == 0)
11843-
return PyBool_FromLong(0);
11843+
Py_RETURN_FALSE;
1184411844

1184511845
cased = 0;
1184611846
previous_is_cased = 0;
@@ -11849,13 +11849,13 @@ unicode_istitle_impl(PyObject *self)
1184911849

1185011850
if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) {
1185111851
if (previous_is_cased)
11852-
return PyBool_FromLong(0);
11852+
Py_RETURN_FALSE;
1185311853
previous_is_cased = 1;
1185411854
cased = 1;
1185511855
}
1185611856
else if (Py_UNICODE_ISLOWER(ch)) {
1185711857
if (!previous_is_cased)
11858-
return PyBool_FromLong(0);
11858+
Py_RETURN_FALSE;
1185911859
previous_is_cased = 1;
1186011860
cased = 1;
1186111861
}
@@ -11895,14 +11895,14 @@ unicode_isspace_impl(PyObject *self)
1189511895

1189611896
/* Special case for empty strings */
1189711897
if (length == 0)
11898-
return PyBool_FromLong(0);
11898+
Py_RETURN_FALSE;
1189911899

1190011900
for (i = 0; i < length; i++) {
1190111901
const Py_UCS4 ch = PyUnicode_READ(kind, data, i);
1190211902
if (!Py_UNICODE_ISSPACE(ch))
11903-
return PyBool_FromLong(0);
11903+
Py_RETURN_FALSE;
1190411904
}
11905-
return PyBool_FromLong(1);
11905+
Py_RETURN_TRUE;
1190611906
}
1190711907

1190811908
/*[clinic input]
@@ -11935,13 +11935,13 @@ unicode_isalpha_impl(PyObject *self)
1193511935

1193611936
/* Special case for empty strings */
1193711937
if (length == 0)
11938-
return PyBool_FromLong(0);
11938+
Py_RETURN_FALSE;
1193911939

1194011940
for (i = 0; i < length; i++) {
1194111941
if (!Py_UNICODE_ISALPHA(PyUnicode_READ(kind, data, i)))
11942-
return PyBool_FromLong(0);
11942+
Py_RETURN_FALSE;
1194311943
}
11944-
return PyBool_FromLong(1);
11944+
Py_RETURN_TRUE;
1194511945
}
1194611946

1194711947
/*[clinic input]
@@ -11976,14 +11976,14 @@ unicode_isalnum_impl(PyObject *self)
1197611976

1197711977
/* Special case for empty strings */
1197811978
if (len == 0)
11979-
return PyBool_FromLong(0);
11979+
Py_RETURN_FALSE;
1198011980

1198111981
for (i = 0; i < len; i++) {
1198211982
const Py_UCS4 ch = PyUnicode_READ(kind, data, i);
1198311983
if (!Py_UNICODE_ISALNUM(ch))
11984-
return PyBool_FromLong(0);
11984+
Py_RETURN_FALSE;
1198511985
}
11986-
return PyBool_FromLong(1);
11986+
Py_RETURN_TRUE;
1198711987
}
1198811988

1198911989
/*[clinic input]
@@ -12016,13 +12016,13 @@ unicode_isdecimal_impl(PyObject *self)
1201612016

1201712017
/* Special case for empty strings */
1201812018
if (length == 0)
12019-
return PyBool_FromLong(0);
12019+
Py_RETURN_FALSE;
1202012020

1202112021
for (i = 0; i < length; i++) {
1202212022
if (!Py_UNICODE_ISDECIMAL(PyUnicode_READ(kind, data, i)))
12023-
return PyBool_FromLong(0);
12023+
Py_RETURN_FALSE;
1202412024
}
12025-
return PyBool_FromLong(1);
12025+
Py_RETURN_TRUE;
1202612026
}
1202712027

1202812028
/*[clinic input]
@@ -12056,13 +12056,13 @@ unicode_isdigit_impl(PyObject *self)
1205612056

1205712057
/* Special case for empty strings */
1205812058
if (length == 0)
12059-
return PyBool_FromLong(0);
12059+
Py_RETURN_FALSE;
1206012060

1206112061
for (i = 0; i < length; i++) {
1206212062
if (!Py_UNICODE_ISDIGIT(PyUnicode_READ(kind, data, i)))
12063-
return PyBool_FromLong(0);
12063+
Py_RETURN_FALSE;
1206412064
}
12065-
return PyBool_FromLong(1);
12065+
Py_RETURN_TRUE;
1206612066
}
1206712067

1206812068
/*[clinic input]
@@ -12095,13 +12095,13 @@ unicode_isnumeric_impl(PyObject *self)
1209512095

1209612096
/* Special case for empty strings */
1209712097
if (length == 0)
12098-
return PyBool_FromLong(0);
12098+
Py_RETURN_FALSE;
1209912099

1210012100
for (i = 0; i < length; i++) {
1210112101
if (!Py_UNICODE_ISNUMERIC(PyUnicode_READ(kind, data, i)))
12102-
return PyBool_FromLong(0);
12102+
Py_RETURN_FALSE;
1210312103
}
12104-
return PyBool_FromLong(1);
12104+
Py_RETURN_TRUE;
1210512105
}
1210612106

1210712107
int

Python/import.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ _imp_lock_held_impl(PyObject *module)
240240
#ifdef WITH_THREAD
241241
return PyBool_FromLong(import_lock_thread != -1);
242242
#else
243-
return PyBool_FromLong(0);
243+
Py_RETURN_FALSE;
244244
#endif
245245
}
246246

0 commit comments

Comments
 (0)