{"action":"created","issue":{"url":"https://api.github.com/repos/google/flatbuffers/issues/278","labels_url":"https://api.github.com/repos/google/flatbuffers/issues/278/labels{/name}","comments_url":"https://api.github.com/repos/google/flatbuffers/issues/278/comments","events_url":"https://api.github.com/repos/google/flatbuffers/issues/278/events","html_url":"https://github.com/google/flatbuffers/issues/278","id":108095515,"number":278,"title":"Python: if a string is more than 64k it will fail at EndObject","user":{"login":"tguo-aa","id":14157039,"avatar_url":"https://avatars.githubusercontent.com/u/14157039?v=3","gravatar_id":"","url":"https://api.github.com/users/tguo-aa","html_url":"https://github.com/tguo-aa","followers_url":"https://api.github.com/users/tguo-aa/followers","following_url":"https://api.github.com/users/tguo-aa/following{/other_user}","gists_url":"https://api.github.com/users/tguo-aa/gists{/gist_id}","starred_url":"https://api.github.com/users/tguo-aa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tguo-aa/subscriptions","organizations_url":"https://api.github.com/users/tguo-aa/orgs","repos_url":"https://api.github.com/users/tguo-aa/repos","events_url":"https://api.github.com/users/tguo-aa/events{/privacy}","received_events_url":"https://api.github.com/users/tguo-aa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-09-24T09:43:54Z","updated_at":"2015-10-08T04:43:05Z","closed_at":null,"body":"I'm using a quite simple IDL:\r\n\r\n    namespace Test;\r\n    table App{\r\n      id:long;\r\n      name:string;\r\n      url:string;\r\n    }\r\n    root_type App;\r\n\r\nWhen I tried to assign a 64k string to it, it failed with the following stack trace:\r\n\r\n      File \"/Users/tguo/workspace/python/Test/App.py\", line 47, in AppEnd\r\n        def AppEnd(builder): return builder.EndObject()\r\n      File \"build/bdist.macosx-10.10-intel/egg/flatbuffers/builder.py\", line 243, in EndObject\r\n      File \"build/bdist.macosx-10.10-intel/egg/flatbuffers/builder.py\", line 200, in WriteVtable\r\n      File \"build/bdist.macosx-10.10-intel/egg/flatbuffers/builder.py\", line 498, in PrependVOffsetT\r\n      File \"build/bdist.macosx-10.10-intel/egg/flatbuffers/builder.py\", line 416, in Prepend\r\n      File \"build/bdist.macosx-10.10-intel/egg/flatbuffers/builder.py\", line 506, in Place\r\n      File \"build/bdist.macosx-10.10-intel/egg/flatbuffers/number_types.py\", line 150, in enforce_number\r\n    TypeError: bad number 124460 for type uint16\r\n\r\nAnd here's how I use it:\r\n\r\n    large_content = '' \r\n    with open('data', 'r') as f:\r\n        large_content = f.read()\r\n    # which is more than 64k\r\n    ...\r\n    b = flatbuffers.Builder(0)\r\n    App.AppStart(b)\r\n    url = b.CreateString(large_content)\r\n    App.AppAddUrl(b, url)\r\n    app = App.AppEnd(b)\r\n\r\nI checked the code builder.py:\r\n\r\nline 198, the \"off\" is calculated by \"objectOffset\", which is get by self.Offset(), which would return a UOffsetTFlags, \r\n`off = objectOffset - self.current_vtable[i]`\r\n\r\n    def Offset(self):\r\n        \"\"\"Offset relative to the end of the buffer.\"\"\"\r\n        return UOffsetTFlags.py_type(len(self.Bytes) - self.Head())\r\nwhich is uint32:\r\n\r\n    class UOffsetTFlags(Uint32Flags):\r\n        pass\r\n\r\nHowever in line 200->498, it passes a \"N.VOffsetTFlags\" which is uint 16.\r\n`def PrependVOffsetT(self, x): self.Prepend(N.VOffsetTFlags, x)`\r\n\r\n    class VOffsetTFlags(Uint16Flags):\r\n        pass\r\n\r\nI guess this is the root cause but I tried to change N.VOffsetTFlags to inherite Uint32Flags and failed.\r\n\r\nIs this a bug or I'm not using it right?"},"comment":{"url":"https://api.github.com/repos/google/flatbuffers/issues/comments/146418564","html_url":"https://github.com/google/flatbuffers/issues/278#issuecomment-146418564","issue_url":"https://api.github.com/repos/google/flatbuffers/issues/278","id":146418564,"user":{"login":"tguo-aa","id":14157039,"avatar_url":"https://avatars.githubusercontent.com/u/14157039?v=3","gravatar_id":"","url":"https://api.github.com/users/tguo-aa","html_url":"https://github.com/tguo-aa","followers_url":"https://api.github.com/users/tguo-aa/followers","following_url":"https://api.github.com/users/tguo-aa/following{/other_user}","gists_url":"https://api.github.com/users/tguo-aa/gists{/gist_id}","starred_url":"https://api.github.com/users/tguo-aa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tguo-aa/subscriptions","organizations_url":"https://api.github.com/users/tguo-aa/orgs","repos_url":"https://api.github.com/users/tguo-aa/repos","events_url":"https://api.github.com/users/tguo-aa/events{/privacy}","received_events_url":"https://api.github.com/users/tguo-aa/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T04:43:05Z","updated_at":"2015-10-08T04:43:05Z","body":"https://github.com/google/flatbuffers/pull/286\r\n\r\nPlease review"}}