{"action":"created","issue":{"url":"https://api.github.com/repos/tinylib/msgp/issues/134","labels_url":"https://api.github.com/repos/tinylib/msgp/issues/134/labels{/name}","comments_url":"https://api.github.com/repos/tinylib/msgp/issues/134/comments","events_url":"https://api.github.com/repos/tinylib/msgp/issues/134/events","html_url":"https://github.com/tinylib/msgp/issues/134","id":110561798,"number":134,"title":"question: on uint vs. int decoding.","user":{"login":"client9","id":217179,"avatar_url":"https://avatars.githubusercontent.com/u/217179?v=3","gravatar_id":"","url":"https://api.github.com/users/client9","html_url":"https://github.com/client9","followers_url":"https://api.github.com/users/client9/followers","following_url":"https://api.github.com/users/client9/following{/other_user}","gists_url":"https://api.github.com/users/client9/gists{/gist_id}","starred_url":"https://api.github.com/users/client9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/client9/subscriptions","organizations_url":"https://api.github.com/users/client9/orgs","repos_url":"https://api.github.com/users/client9/repos","events_url":"https://api.github.com/users/client9/events{/privacy}","received_events_url":"https://api.github.com/users/client9/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-10-08T23:38:07Z","updated_at":"2016-01-27T01:58:30Z","closed_at":null,"body":"I started getting some of these errors on decode:\r\n\r\n```\r\nattempted to decode type \"uint\" with method for \"int\"\r\n```\r\n\r\nThe culprit was another msgpack implementation\r\n\r\n```\r\nfunc (e *msgpackEncDriver) EncodeInt(i int64) {\r\n\tif i >= 0 {\r\n\t\te.EncodeUint(uint64(i))\r\n```\r\n\r\nI found a few other libraries doing this trick.  Any suggestions here on how i can morph your library to read them?\r\n\r\nupdate:\r\n\r\nI'll spare you reading lua code, but  \r\nhttps://github.com/fperrad/lua-MessagePack/\r\n\r\nalso defaults to unsigned.\r\n\r\n```\r\nset_integer'unsigned'\r\n```\r\n\r\n\r\nupdate, and one version of python, basically the pattern is \"if non-negative, write as unsigned, if negative write as signed\"\r\n\r\n```\r\n\r\n# You may notice struct.pack(\"B\", obj) instead of the simpler chr(obj) in the\r\n# code below. This is to allow for seamless Python 2 and 3 compatibility, as\r\n# chr(obj) has a str return type instead of bytes in Python 3, and\r\n# struct.pack(...) has the right return type in both versions.\r\n\r\ndef _pack_integer(obj, fp):\r\n    if obj < 0:\r\n        if obj >= -32:\r\n            fp.write(struct.pack(\"b\", obj))\r\n        elif obj >= -2**(8-1):\r\n            fp.write(b\"\\xd0\" + struct.pack(\"b\", obj))\r\n        elif obj >= -2**(16-1):\r\n            fp.write(b\"\\xd1\" + struct.pack(\">h\", obj))\r\n        elif obj >= -2**(32-1):\r\n            fp.write(b\"\\xd2\" + struct.pack(\">i\", obj))\r\n        elif obj >= -2**(64-1):\r\n            fp.write(b\"\\xd3\" + struct.pack(\">q\", obj))\r\n        else:\r\n            raise UnsupportedTypeException(\"huge signed int\")\r\n    else:\r\n        if obj <= 127:\r\n            fp.write(struct.pack(\"B\", obj))\r\n        elif obj <= 2**8-1:\r\n            fp.write(b\"\\xcc\" + struct.pack(\"B\", obj))\r\n        elif obj <= 2**16-1:\r\n            fp.write(b\"\\xcd\" + struct.pack(\">H\", obj))\r\n        elif obj <= 2**32-1:\r\n            fp.write(b\"\\xce\" + struct.pack(\">I\", obj))\r\n        elif obj <= 2**64-1:\r\n            fp.write(b\"\\xcf\" + struct.pack(\">Q\", obj))\r\n        else:\r\n            raise UnsupportedTypeException(\"huge unsigned int\")\r\n```"},"comment":{"url":"https://api.github.com/repos/tinylib/msgp/issues/comments/175341131","html_url":"https://github.com/tinylib/msgp/issues/134#issuecomment-175341131","issue_url":"https://api.github.com/repos/tinylib/msgp/issues/134","id":175341131,"user":{"login":"client9","id":217179,"avatar_url":"https://avatars.githubusercontent.com/u/217179?v=3","gravatar_id":"","url":"https://api.github.com/users/client9","html_url":"https://github.com/client9","followers_url":"https://api.github.com/users/client9/followers","following_url":"https://api.github.com/users/client9/following{/other_user}","gists_url":"https://api.github.com/users/client9/gists{/gist_id}","starred_url":"https://api.github.com/users/client9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/client9/subscriptions","organizations_url":"https://api.github.com/users/client9/orgs","repos_url":"https://api.github.com/users/client9/repos","events_url":"https://api.github.com/users/client9/events{/privacy}","received_events_url":"https://api.github.com/users/client9/received_events","type":"User","site_admin":false},"created_at":"2016-01-27T01:58:30Z","updated_at":"2016-01-27T01:58:30Z","body":"@dwlnetnl go for it!"}}