{"action":"opened","issue":{"url":"https://api.github.com/repos/etetoolkit/ete/issues/276","repository_url":"https://api.github.com/repos/etetoolkit/ete","labels_url":"https://api.github.com/repos/etetoolkit/ete/issues/276/labels{/name}","comments_url":"https://api.github.com/repos/etetoolkit/ete/issues/276/comments","events_url":"https://api.github.com/repos/etetoolkit/ete/issues/276/events","html_url":"https://github.com/etetoolkit/ete/issues/276","id":218050851,"number":276,"title":"ResourceWarning on using ete3.Tree.render()","user":{"login":"davidhwyllie","id":12086794,"avatar_url":"https://avatars0.githubusercontent.com/u/12086794?v=3","gravatar_id":"","url":"https://api.github.com/users/davidhwyllie","html_url":"https://github.com/davidhwyllie","followers_url":"https://api.github.com/users/davidhwyllie/followers","following_url":"https://api.github.com/users/davidhwyllie/following{/other_user}","gists_url":"https://api.github.com/users/davidhwyllie/gists{/gist_id}","starred_url":"https://api.github.com/users/davidhwyllie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidhwyllie/subscriptions","organizations_url":"https://api.github.com/users/davidhwyllie/orgs","repos_url":"https://api.github.com/users/davidhwyllie/repos","events_url":"https://api.github.com/users/davidhwyllie/events{/privacy}","received_events_url":"https://api.github.com/users/davidhwyllie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-30T00:52:08Z","updated_at":"2017-03-30T00:52:08Z","closed_at":null,"body":"Hi\r\n\r\nI am using python 3.5.2 on Windows with ete 3.0.0b35.  I have an application which can make thousands of trees as part of a bacterial surveillance project.  I have noticed that a resource warning is generated on my system during this process.  To reproduce, one can use this script:\r\n\r\n```\r\nimport ete3\r\nimport os\r\nimport unittest\r\n\r\nclass test_treeview_write(unittest.TestCase):\r\n    def runTest(self):\r\n        \"\"\" writes to disc, giving a ResourceWarning\r\n        \"\"\"\r\n        print(\"Running unit test\")\r\n        newick_text = '(A:0.1,B:0.2,(C:0.3,D:0.4):0.5);'\r\n        \r\n        # create tree\r\n        t = ete3.Tree(newick_text)\r\n        \r\n        # export the tree in png format      \r\n        t.render(\"t1.svg\", tree_style=ete3.TreeStyle())\r\n```\r\nAnd then (if the test file is called myTest.py) do\r\n```\r\npython -m unittest myTest\r\n```\r\n\r\nI get this:\r\n```\r\nRunning unit test\r\nC:\\python352\\lib\\site-packages\\ete3\\treeview\\main.py:705: ResourceWarning: unclo\r\nsed file <_io.TextIOWrapper name='t1.svg' mode='r' encoding='cp1252'>\r\n  compatible_code = open(imgName).read()\r\nC:\\python352\\lib\\site-packages\\ete3\\treeview\\main.py:720: ResourceWarning: unclo\r\nsed file <_io.TextIOWrapper name='t1.svg' mode='w' encoding='cp1252'>\r\n  open(imgName, \"w\").write(compatible_code)\r\n```\r\n\r\nThis is I think about different 2/3 behaviour, cf. possibly related discussion:\r\nhttps://github.com/python-pillow/Pillow/issues/477\r\nAnyway, it's easily resolved (tested ):  Replacement for  line 705:\r\n```\r\n            with open(imgName,'rt') as f:\r\n                compatible_code = f.read()\r\n```\r\nReplacement for line 720:\r\n```\r\n            with open(imgName, \"w\") as f:\r\n                f.write(compatible_code)\r\n```\r\n\r\nWould you consider patching this?\r\nThank you\r\n"}}
{"actor":{"display_login":"davidhwyllie"}}