Skip to content

Commit 33e6314

Browse files
committed
Use bytes() instead of str()
bytes() is more accurate and is actually correct in Python 3, whereas str() is incorrect in Python 3, because it's a Unicode string.
1 parent c0b94c6 commit 33e6314

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

smmap/buf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
__all__ = ["SlidingWindowMapBuffer"]
77

8+
try:
9+
bytes
10+
except NameError:
11+
bytes = str
12+
13+
814
class SlidingWindowMapBuffer(object):
915
"""A buffer like object which allows direct byte-wise object and slicing into
1016
memory of a mapped file. The mapping is controlled by the provided cursor.
@@ -73,7 +79,7 @@ def __getslice__(self, i, j):
7379
ofs = i
7480
# Keeping tokens in a list could possible be faster, but the list
7581
# overhead outweighs the benefits (tested) !
76-
md = str()
82+
md = bytes()
7783
while l:
7884
c.use_region(ofs, l)
7985
assert c.is_valid()

0 commit comments

Comments
 (0)