Skip to content

Commit 7c826d2

Browse files
committed
Merge branch 'byte-find' of https://github.com/syphar/python-future
2 parents 4a780e1 + 76b04c7 commit 7c826d2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

future/builtins/types/newbytes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ def fromhex(cls, string):
163163

164164
@no(unicode)
165165
def find(self, sub, *args):
166-
return newbytes(super(newbytes, self).find(sub, *args))
166+
return super(newbytes, self).find(sub, *args)
167167

168168
@no(unicode)
169169
def rfind(self, sub, *args):
170-
return newbytes(super(newbytes, self).rfind(sub, *args))
170+
return super(newbytes, self).rfind(sub, *args)
171171

172172
@no(unicode, (1, 2))
173173
def replace(self, old, new, *args):

future/tests/test_bytes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ def test_bytes_plus_bytes(self):
168168
self.assertEqual(b4, b'ZYXWABCD')
169169
self.assertTrue(isinstance(b4, bytes))
170170

171+
def test_find_not_found(self):
172+
self.assertEqual(-1, bytes(b'ABCDE').find(b':'))
173+
174+
def test_find_found(self):
175+
self.assertEqual(2, bytes(b'AB:CD:E').find(b':'))
176+
177+
def test_rfind_not_found(self):
178+
self.assertEqual(-1, bytes(b'ABCDE').find(b':'))
179+
180+
def test_rfind_found(self):
181+
self.assertEqual(4, bytes(b'AB:CD:E').find(b':'))
182+
171183
def test_bytes_join_bytes(self):
172184
b = bytes(b' * ')
173185
strings = [b'AB', b'EFGH', b'IJKL']

0 commit comments

Comments
 (0)