From e2096897b570ae270fc7edba309611331ab8dc2b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sun, 30 Sep 2007 23:19:14 +0000 Subject: [PATCH] Changed my mind on comparing bytes to str. --- pep-3137.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pep-3137.txt b/pep-3137.txt index ef8b0ad51..51070dce6 100644 --- a/pep-3137.txt +++ b/pep-3137.txt @@ -8,7 +8,7 @@ Type: Standards Track Content-Type: text/x-rst Created: 26-Sep-2007 Python-Version: 3.0 -Post-History: 26-Sep-2007 +Post-History: 26-Sep-2007, 30-Sep-2007 Introduction ============ @@ -124,8 +124,18 @@ Comparisons The bytes and buffer types are comparable with each other and orderable, so that e.g. b'abc' == buffer(b'abc') < b'abd'. -Comparing either type to a str object raises an exception. This -turned out to be necessary to catch common mistakes. +Comparing either type to a str object for equality returns False +regardless of the contents of either operand. Ordering comparisons +with str raise TypeError. This is all conformant to the standard +rules for comparison and ordering between objects of incompatible +types. + +(**Note:** in Python 3.0a1, comparing a bytes instance with a str +instance would raise TypeError, on the premise that this would catch +the occasional mistake quicker, especially in code ported from Python +2.x. However, a long discussion on the python-3000 list pointed out +so many problems with this that it is clearly a bad idea, to be rolled +back in 3.0a2 regardless of the fate of the rest of this PEP.) Slicing -------