summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2016-09-12 08:48:55 (GMT)
committerChristian Heimes <christian@python.org>2016-09-12 08:48:55 (GMT)
commit4d9a72902dec55fe87f105324adc4239a13d966f (patch)
tree12336d19f4aa31e4ef9d2687883006395c474b5d /Objects
parent9017ec1ea0347c4bd901c329254590a9f86a69b8 (diff)
parent0d5048cb21e431c1a8221e15563837090946be81 (diff)
downloadcpython-4d9a72902dec55fe87f105324adc4239a13d966f.zip
cpython-4d9a72902dec55fe87f105324adc4239a13d966f.tar.gz
cpython-4d9a72902dec55fe87f105324adc4239a13d966f.tar.bz2
merge
Diffstat (limited to 'Objects')
-rw-r--r--Objects/rangeobject.c2
-rw-r--r--Objects/setobject.c8
2 files changed, 9 insertions, 1 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 8e74132..e7c3709 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -399,7 +399,7 @@ range_contains_long(rangeobject *r, PyObject *ob)
tmp2 = PyNumber_Remainder(tmp1, r->step);
if (tmp2 == NULL)
goto end;
- /* result = (int(ob) - start % step) == 0 */
+ /* result = ((int(ob) - start) % step) == 0 */
result = PyObject_RichCompareBool(tmp2, zero, Py_EQ);
end:
Py_XDECREF(tmp1);
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 6dd403f..5846045 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1476,6 +1476,10 @@ PyDoc_STRVAR(isdisjoint_doc,
static int
set_difference_update_internal(PySetObject *so, PyObject *other)
{
+ if (PySet_GET_SIZE(so) == 0) {
+ return 0;
+ }
+
if ((PyObject *)so == other)
return set_clear_internal(so);
@@ -1550,6 +1554,10 @@ set_difference(PySetObject *so, PyObject *other)
Py_ssize_t pos = 0;
int rv;
+ if (PySet_GET_SIZE(so) == 0) {
+ return set_copy(so);
+ }
+
if (!PyAnySet_Check(other) && !PyDict_CheckExact(other)) {
return set_copy_and_difference(so, other);
}