mjuenema / python-TSIP

Python library for parsing and creating TSIP packets used for communicating with a Trimble GPS receiver.
BSD 2-Clause "Simplified" License
6 stars 6 forks source link

Python 3: TypeError: 'str' does not support the buffer interface #9

Closed mjuenema closed 8 years ago

mjuenema commented 8 years ago
py34 create: /home/developer/python-TSIP/.tox/py34
py34 installdeps: -r/home/developer/python-TSIP/requirements.txt, -r/home/developer/python-TSIP/test_requirements.txt
py34 inst: /home/developer/python-TSIP/.tox/dist/tsip-0.2.0.zip
py34 installed: coverage==4.0.3,nose==1.3.7,wheel==0.24.0
py34 runtests: PYTHONHASHSEED='1023087779'
py34 runtests: commands[0] | nosetests --cover-erase
test_hlapi.Test0x1c01.test_pack ... > /home/developer/python-TSIP/tsip/structs.py(446)get_structs_for_rawpacket()
-> key = struct.unpack('>B', rawpacket[0])[0]
(Pdb) 
ERROR

======================================================================
ERROR: test_hlapi.Test0x1c01.test_pack
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/developer/python-TSIP/.tox/py34/lib/python3.4/site-packages/nose/case.py", line 382, in setUp
    try_run(self.inst, ('setup', 'setUp'))
  File "/home/developer/python-TSIP/.tox/py34/lib/python3.4/site-packages/nose/util.py", line 471, in try_run
    return func()
  File "/home/developer/python-TSIP/tests/test_hlapi.py", line 13, in setup
    self.pkt2 = Packet.unpack(self.rawpacket)
  File "/home/developer/python-TSIP/tsip/hlapi.py", line 125, in unpack
    structs_ = get_structs_for_rawpacket(rawpacket)
  File "/home/developer/python-TSIP/tsip/structs.py", line 446, in get_structs_for_rawpacket
    key = struct.unpack('>B', rawpacket[0])[0]
TypeError: 'str' does not support the buffer interface
mjuenema commented 8 years ago

http://python3porting.com/problems.html: Bytes, strings and Unicode

mjuenema commented 8 years ago

struct.unpack on a bytearray that works under Python 2.6.6, 2.7 and 3.3? http://codereview.stackexchange.com/questions/37959/struct-unpack-on-a-bytearray-that-works-under-python-2-6-6-2-7-and-3-3