diff Objects/bytesobject.c @ 41412:522b3f35d0eb

Bytes should never equal unicode. Add tests for str <cmpop> bytes.
author Guido van Rossum <guido@python.org>
date Mon, 09 Apr 2007 00:49:13 +0000
parents 339015d98b78
children 4561f6da3b7d
line wrap: on
line diff
--- a/Objects/bytesobject.c	Mon Apr 09 00:43:24 2007 +0000
+++ b/Objects/bytesobject.c	Mon Apr 09 00:49:13 2007 +0000
@@ -848,7 +848,12 @@
     int cmp;
 
     /* For backwards compatibility, bytes can be compared to anything that
-       supports the (binary) buffer API. */
+       supports the (binary) buffer API.  Except Unicode. */
+
+    if (PyUnicode_Check(self) || PyUnicode_Check(other)) {
+        Py_INCREF(Py_NotImplemented);
+        return Py_NotImplemented;
+    }
 
     self_buffer = self->ob_type->tp_as_buffer;
     if (self_buffer == NULL ||