Can't pass endian argument to p_uint64.from_str
Closed this issue · 3 comments
ronaldoussoren commented
Original report by Asger Hautop Drewsen (Bitbucket: tyilo, GitHub: tyilo).
It looks like the MetaPackable's from_str
method accepts an _endian_
keyword argument:
#!python
def from_str(cls, s, **kw):
endian = kw.get('_endian_', cls._endian_)
return cls.from_tuple(struct.unpack(endian + cls._format_, s), **kw)
However it doesn't actually work:
#!python
macholib.ptypes.p_uint64.from_str('\x01\x00\x00\x00\x00\x00\x00\x00', _endian_='<')
Here is the exception I get from iPython:
TypeError Traceback (most recent call last)
<ipython-input-25-8cdc68314575> in <module>()
----> 1 macholib.ptypes.p_uint64.from_str('\x01\x00\x00\x00\x00\x00\x00\x00', _endian_='<')
/Users/Tyilo/repos/macholib/macholib/ptypes.py in from_str(cls, s, **kw)
65 def from_str(cls, s, **kw):
66 endian = kw.get('_endian_', cls._endian_)
---> 67 return cls.from_tuple(struct.unpack(endian + cls._format_, s), **kw)
68
69 def from_tuple(cls, tpl, **kw):
/Users/Tyilo/repos/macholib/macholib/ptypes.py in from_tuple(cls, tpl, **kw)
68
69 def from_tuple(cls, tpl, **kw):
---> 70 return cls(tpl[0], **kw)
71
72 class BasePackable(object):
TypeError: '_endian_' is an invalid keyword argument for this function
ronaldoussoren commented
ronaldoussoren commented
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).
I'm reopening this issue because the patch breaks py2app.
ronaldoussoren commented
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).
changeset 5147f2d46dd5 fixes the issue