Skip to content

Commit

Permalink
Fix byte2int() for Python 3
Browse files Browse the repository at this point in the history
Provides a fix for byte2int() using the Python 2 implemention on Python
3 when the "six" module isn't present
  • Loading branch information
SE2Dev committed Jan 14, 2018
1 parent 5a865e7 commit 20a2909
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions _lz4.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
except ImportError:
xrange = range

def byte2int(_bytes):
return ord(_bytes[0])
# If we're running Python 3 or newer, we must
# define byte2int differently than with Python 2
import sys
if sys.version_info[0] >= 3:
import operator
byte2int = operator.itemgetter(0)
else:
def byte2int(_bytes):
return ord(_bytes[0])

class CorruptError(Exception):
pass
Expand Down

0 comments on commit 20a2909

Please sign in to comment.