summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytesobject.c25
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;
}