Skip to content

Commit 6ab100d

Browse files
authored
Merge pull request #5 from thalesmello/bugfix/fix-byte-math-on-python3
Fix byte to integer conversion
2 parents 0874929 + d283f2d commit 6ab100d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

erlang.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def _binary_to_term(i, data):
603603
)
604604
return (i + j, OtpErlangAtom(atom_name))
605605
elif tag == _TAG_SMALL_ATOM_UTF8_EXT:
606-
j = b_ord(data[i:i + 1])
606+
j = b_ord(data[i])
607607
i += 1
608608
atom_name = TypeUnicode(
609609
data[i:i + j], encoding='utf-8', errors='strict'

tests/erlang_tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def test_binary_to_term_atom(self):
128128
erlang.binary_to_term(b'\x83d\0\4test'))
129129
self.assertEqual(erlang.OtpErlangAtom(b'test'),
130130
erlang.binary_to_term(b'\x83s\4test'))
131+
self.assertEqual(erlang.OtpErlangAtom(u'name'),
132+
erlang.binary_to_term(b'\x83w\x04name'))
131133
def test_binary_to_term_predefined_atoms(self):
132134
self.assertEqual(True, erlang.binary_to_term(b'\x83s\4true'))
133135
self.assertEqual(False, erlang.binary_to_term(b'\x83s\5false'))

0 commit comments

Comments
 (0)