mtiller / recon

Web and network friendly simulation data formats
MIT License
8 stars 4 forks source link

TypeError on fullRobot.mld #37

Closed tbeu closed 10 years ago

tbeu commented 10 years ago

I converted fullRobot.mat to mld using script dsres2meld. Then I got:

PythonWin 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32.
>>> from recon.meld import MeldWriter, MeldReader
>>> fp = open(r'c:\Download\recon-master\tests\fullRobot.mld', 'rb')
>>> meld = MeldReader(fp, verbose=True)
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Programme\Python27\lib\site-packages\pyrecon-0.3.0-py2.7.egg\recon\meld.py", line 444, in __init__
    self.header = self.ser.decode_obj(self.fp, length=blen)
  File "C:\Programme\Python27\lib\site-packages\pyrecon-0.3.0-py2.7.egg\recon\serial.py", line 107, in decode_obj
    x = msgpack.unpackb(data)
  File "_unpacker.pyx", line 119, in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:119)
TypeError: unhashable type: 'dict'

Environment is WinXP with Python 2.7.6, setuptools 2.2 and msgpack-python 0.4.1.

xogeny commented 10 years ago

Thomas,

Where did the fullRobot.mld file come from? When the tests run, they produce a file called dsres_robot.mld. I was trying to see if I could reproduce this issue on my Mac, but I'm not sure how you produced the fullRobot.mld file.

tbeu commented 10 years ago

See first sentence above: I converted fullRobot.mat to mld using script dsres2meld. If helpful I can provide fullRobot.mld later.

xogeny commented 10 years ago

My fault. Sorry I didn't see the first sentence.

xogeny commented 10 years ago

Just another note (again, mostly to myself), that I'm unable to reproduce this issue on my Mac. I'll try Linux and Windows when I can.

(this is using Python 2.7.5)

tbeu commented 10 years ago

Just to make sure that there is no error in dsres2meld. Here is the file: http://www.FastShare.org/download/fullRobot.zip

tbeu commented 10 years ago

This is the traceback if the fallback pure python implementation of msgpack is used

>>> meld = MeldReader(fp, verbose=True)
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Programme\Python27\lib\site-packages\pyrecon-0.3.0-py2.7.egg\recon\meld.py", line 445, in __init__
    self.header = self.ser.decode_obj(self.fp, length=blen)
  File "C:\Programme\Python27\lib\site-packages\pyrecon-0.3.0-py2.7.egg\recon\serial.py", line 107, in decode_obj
    x = msgpack.unpackb(data)
  File "C:\Programme\Python27\lib\site-packages\msgpack_python-0.4.1-py2.7-win32.egg\msgpack\fallback.py", line 93, in unpackb
    ret = unpacker._fb_unpack()
  File "C:\Programme\Python27\lib\site-packages\msgpack_python-0.4.1-py2.7-win32.egg\msgpack\fallback.py", line 423, in _fb_unpack
    ret[key] = self._fb_unpack(EX_CONSTRUCT, write_bytes)
  File "C:\Programme\Python27\lib\site-packages\msgpack_python-0.4.1-py2.7-win32.egg\msgpack\fallback.py", line 423, in _fb_unpack
    ret[key] = self._fb_unpack(EX_CONSTRUCT, write_bytes)
  File "C:\Programme\Python27\lib\site-packages\msgpack_python-0.4.1-py2.7-win32.egg\msgpack\fallback.py", line 423, in _fb_unpack
    ret[key] = self._fb_unpack(EX_CONSTRUCT, write_bytes)
  File "C:\Programme\Python27\lib\site-packages\msgpack_python-0.4.1-py2.7-win32.egg\msgpack\fallback.py", line 423, in _fb_unpack
    ret[key] = self._fb_unpack(EX_CONSTRUCT, write_bytes)
TypeError: unhashable type: 'dict'
xogeny commented 10 years ago

I strongly suspect this is related to #38. It appears that Windows is writing incorrect indices in the meld file and this could trigger all kinds of problems. So we need to focus on making sure the indices are correct and then check both this issue and #38 to see if they persist.

tbeu commented 10 years ago

Fix confirmed. Thank you!

xogeny commented 10 years ago

Whew! Thanks for all your help. It turned out the issue was that although I had opened the files for reading binary, I had not opened them for writing binary. Pretty stupid mistake on my part. :-(

I modified both the translate scripts so anyone using them should be protected. It is still possible that people using the library might open a file for reading or writing in non-binary mode. I don't know any way to protect people in such cases though.

xogeny commented 10 years ago

For reference, the fix was committed in 50c48a0f8d264dd2619f42c214db1eedd03e5c76.