diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-20 14:54:57 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-20 14:54:57 (GMT) |
commit | 1dd49824df49d0132b21d90c12bb596da89d7a17 (patch) | |
tree | 7c76fae39c0d2160d8abcb5e908d7b46a9cd8f01 /Objects | |
parent | ee4c0b9dcfb550094cca086a032d44393b5c3642 (diff) | |
download | cpython-1dd49824df49d0132b21d90c12bb596da89d7a17.zip cpython-1dd49824df49d0132b21d90c12bb596da89d7a17.tar.gz cpython-1dd49824df49d0132b21d90c12bb596da89d7a17.tar.bz2 |
Issue #23681: The -b option now affects comparisons of bytes with int.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytesobject.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index e0ac1ab..5a9dfbd 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1385,14 +1385,23 @@ bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op) /* Make sure both arguments are strings. */ if (!(PyBytes_Check(a) && PyBytes_Check(b))) { - if (Py_BytesWarningFlag && (op == Py_EQ || op == Py_NE) && - (PyObject_IsInstance((PyObject*)a, - (PyObject*)&PyUnicode_Type) || - PyObject_IsInstance((PyObject*)b, - (PyObject*)&PyUnicode_Type))) { - if (PyErr_WarnEx(PyExc_BytesWarning, - "Comparison between bytes and string", 1)) - return NULL; + if (Py_BytesWarningFlag && (op == Py_EQ || op == Py_NE)) { + if (PyObject_IsInstance((PyObject*)a, + (PyObject*)&PyUnicode_Type) || + PyObject_IsInstance((PyObject*)b, + (PyObject*)&PyUnicode_Type)) { + if (PyErr_WarnEx(PyExc_BytesWarning, + "Comparison between bytes and string", 1)) + return NULL; + } + else if (PyObject_IsInstance((PyObject*)a, + (PyObject*)&PyLong_Type) || + PyObject_IsInstance((PyObject*)b, + (PyObject*)&PyLong_Type)) { + if (PyErr_WarnEx(PyExc_BytesWarning, + "Comparison between bytes and int", 1)) + return NULL; + } } result = Py_NotImplemented; } |