Skip to content

Commit

Permalink
fix: Indexing bytes produces int on python3 for pssh-box.py (sh…
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlei authored Jul 12, 2023
1 parent ac47e52 commit d9d3c7f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packager/tools/pssh/pssh-box.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
import struct
import sys


def to_code_point(value):
"""
Return the unicode code point with `int` passthrough
"""
if isinstance(value, int):
return value

return ord(value)


_script_dir = os.path.dirname(os.path.realpath(__file__))
_proto_path = os.path.join(_script_dir, 'pyproto')
_widevine_proto_path = os.path.join(_proto_path, 'packager/media/base')
Expand Down Expand Up @@ -64,9 +75,9 @@ def read_int(self, size):
ret = 0
for i in range(0, size):
if self.little_endian:
ret |= (ord(data[i]) << (8 * i))
ret |= (to_code_point(data[i]) << (8 * i))
else:
ret |= (ord(data[i]) << (8 * (size - i - 1)))
ret |= (to_code_point(data[i]) << (8 * (size - i - 1)))
return ret


Expand Down

0 comments on commit d9d3c7f

Please sign in to comment.