summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
author4kir4 <4kir4.1i@gmail.com>2017-03-20 06:44:46 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-03-20 06:44:46 (GMT)
commite46fb8611867fa3b407a813f53137929b7cb4a10 (patch)
tree9165a0264f38ddfd82cce4080b190f1b5225e95d /Objects
parent64508780d72769e4c7afc67a511c057261c578f6 (diff)
downloadcpython-e46fb8611867fa3b407a813f53137929b7cb4a10.zip
cpython-e46fb8611867fa3b407a813f53137929b7cb4a10.tar.gz
cpython-e46fb8611867fa3b407a813f53137929b7cb4a10.tar.bz2
bpo-28876: bool of large range raises OverflowError (#699)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/rangeobject.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 45c557f..820fea5 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -668,6 +668,16 @@ static PyMappingMethods range_as_mapping = {
(objobjargproc)0, /* mp_ass_subscript */
};
+static int
+range_bool(rangeobject* self)
+{
+ return PyObject_IsTrue(self->length);
+}
+
+static PyNumberMethods range_as_number = {
+ .nb_bool = (inquiry)range_bool,
+};
+
static PyObject * range_iter(PyObject *seq);
static PyObject * range_reverse(PyObject *seq);
@@ -707,7 +717,7 @@ PyTypeObject PyRange_Type = {
0, /* tp_setattr */
0, /* tp_reserved */
(reprfunc)range_repr, /* tp_repr */
- 0, /* tp_as_number */
+ &range_as_number, /* tp_as_number */
&range_as_sequence, /* tp_as_sequence */
&range_as_mapping, /* tp_as_mapping */
(hashfunc)range_hash, /* tp_hash */