{"action":"created","issue":{"url":"https://api.github.com/repos/anthill/koala/issues/130","repository_url":"https://api.github.com/repos/anthill/koala","labels_url":"https://api.github.com/repos/anthill/koala/issues/130/labels{/name}","comments_url":"https://api.github.com/repos/anthill/koala/issues/130/comments","events_url":"https://api.github.com/repos/anthill/koala/issues/130/events","html_url":"https://github.com/anthill/koala/issues/130","id":320722888,"number":130,"title":"Basic.py throws a TypeError","user":{"login":"mkpathcreate","id":3972247,"avatar_url":"https://avatars3.githubusercontent.com/u/3972247?v=4","gravatar_id":"","url":"https://api.github.com/users/mkpathcreate","html_url":"https://github.com/mkpathcreate","followers_url":"https://api.github.com/users/mkpathcreate/followers","following_url":"https://api.github.com/users/mkpathcreate/following{/other_user}","gists_url":"https://api.github.com/users/mkpathcreate/gists{/gist_id}","starred_url":"https://api.github.com/users/mkpathcreate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkpathcreate/subscriptions","organizations_url":"https://api.github.com/users/mkpathcreate/orgs","repos_url":"https://api.github.com/users/mkpathcreate/repos","events_url":"https://api.github.com/users/mkpathcreate/events{/privacy}","received_events_url":"https://api.github.com/users/mkpathcreate/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-07T08:45:08Z","updated_at":"2018-05-09T23:58:08Z","closed_at":null,"author_association":"NONE","body":"When I run the examples/basic.py it shows a TypeError.\r\n\r\nuser@webserver: python3 examples/basic.py \r\n\r\n./examples/basic.xlsx\r\n___### Initializing Excel Compiler ###___\r\n___### Reading Cells from XLSX ###___\r\nNb of different functions 0\r\nset()\r\n___### Generating Graph ###___\r\nSeeds 66 cells\r\nGraph construction done, 86 nodes, 74 edges, 86 cellmap entries\r\nSerializing to disk...\r\nTraceback (most recent call last):\r\n  File \"examples/basic.py\", line 16, in <module>\r\n    sp.dump(filename.replace(\"xlsx\", \"gzip\"))\r\n  File \"/usr/local/lib/python3.5/dist-packages/koala/Spreadsheet.py\", line 442, in dump\r\n    dump(self, fname)\r\n  File \"/usr/local/lib/python3.5/dist-packages/koala/serializer.py\", line 58, in dump\r\n    outfile.write(str(cell.value) + \"\\n\")\r\n  File \"/usr/lib/python3.5/gzip.py\", line 258, in write\r\n    data = memoryview(data)\r\nTypeError: memoryview: a bytes-like object is required, not 'str'"},"comment":{"url":"https://api.github.com/repos/anthill/koala/issues/comments/387909998","html_url":"https://github.com/anthill/koala/issues/130#issuecomment-387909998","issue_url":"https://api.github.com/repos/anthill/koala/issues/130","id":387909998,"user":{"login":"Brad-eki","id":38775942,"avatar_url":"https://avatars0.githubusercontent.com/u/38775942?v=4","gravatar_id":"","url":"https://api.github.com/users/Brad-eki","html_url":"https://github.com/Brad-eki","followers_url":"https://api.github.com/users/Brad-eki/followers","following_url":"https://api.github.com/users/Brad-eki/following{/other_user}","gists_url":"https://api.github.com/users/Brad-eki/gists{/gist_id}","starred_url":"https://api.github.com/users/Brad-eki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Brad-eki/subscriptions","organizations_url":"https://api.github.com/users/Brad-eki/orgs","repos_url":"https://api.github.com/users/Brad-eki/repos","events_url":"https://api.github.com/users/Brad-eki/events{/privacy}","received_events_url":"https://api.github.com/users/Brad-eki/received_events","type":"User","site_admin":false},"created_at":"2018-05-09T23:58:07Z","updated_at":"2018-05-09T23:58:07Z","author_association":"NONE","body":"Hi Guys,\r\n\r\nIn Python 3 strings are natively UTF-8 so attempting to consciously encode them to UTF-8 in Python 3 causes problems. To state the obvious, in Python 2 strings are not UTF-8 encoded.\r\n\r\nDue to this bug report it appears I may have introduced a regression, made an inadequate fix or may have missed something in the excitement to support Python 3.\r\n\r\nWe may well reap great benefit from a re-factor as suggested by @jricardo27 which I suspect will aid the preservation of backwards compatibility.\r\n\r\nAs it appears this has slipped through, we may want to re-assess my changes and likely upgrade the tests to catch this case.\r\n\r\nI am interested in attempting a fix but I can’t make time to start on it until late in the weekend at the earliest.\r\n\r\nCheers\r\n\r\n\r\nFrom: Ricardo Perez [mailto:notifications@github.com]\r\nSent: Wednesday, May 9, 2018 10:31 PM\r\nTo: anthill/koala <koala@noreply.github.com>\r\nCc: Brad Vanree <brad.vanree@ekistica.com.au>; Mention <mention@noreply.github.com>\r\nSubject: Re: [anthill/koala] Basic.py throws a TypeError (#130)\r\n\r\n\r\nIn Python 2 byte strings and text strings are the same unlike Python 3 where they are clearly differentiated.\r\n\r\nChange line 58 in koala/serializer.py from:\r\n\r\noutfile.write(str(cell.value) + \"\\n\")\r\n\r\nto:\r\n\r\noutfile.write((str(cell.value) + \"\\n\").encode('utf-8'))\r\n\r\nThat should be a quick fix, a better solution is to refactor the code and stop mixing unicode, text strings and bytes. Apologies if I don't offer to do it.\r\n\r\nThe long explanation is that outfile is open as a binary file and it expects bytes to be written on it, you probably can open the file in text mode and remove all the encode() when writing to it:\r\n\r\nFrom this:\r\n\r\noutfile = gzip.GzipFile(fname, 'w')\r\n\r\nto this:\r\n\r\noutfile = gzip.GzipFile(fname, mode='wt')\r\n\r\n—\r\nYou are receiving this because you were mentioned.\r\nReply to this email directly, view it on GitHub<https://github.com/anthill/koala/issues/130#issuecomment-387730428>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ak-shif7GEqxgMxDX97nb4J6dIZFudyhks5twuiHgaJpZM4T0nZr>.\r\n\r\nThis email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission.\r\n"}}
{"actor":{"display_login":"Brad-eki"}}