Given that ord() of a bytes object of length 1 is defined, it should

never return a negative number.
This commit is contained in:
Guido van Rossum 2007-05-08 21:05:48 +00:00
parent 2b08b38dea
commit f9e91c9c58
3 changed files with 15 additions and 1 deletions

View file

@ -671,6 +671,11 @@ class BytesTest(unittest.TestCase):
self.assertEqual(b.rstrip(b'im'), b'mississipp')
self.assertEqual(b.rstrip(b'pim'), b'mississ')
def test_ord(self):
b = b'\0A\x7f\x80\xff'
self.assertEqual([ord(b[i:i+1]) for i in range(len(b))],
[0, 65, 127, 128, 255])
# Optimizations:
# __iter__? (optimization)
# __reversed__? (optimization)