mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Given that ord() of a bytes object of length 1 is defined, it should
never return a negative number.
This commit is contained in:
parent
2b08b38dea
commit
f9e91c9c58
3 changed files with 15 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue