{"action":"opened","issue":{"url":"https://api.github.com/repos/malthe/chameleon/issues/246","repository_url":"https://api.github.com/repos/malthe/chameleon","labels_url":"https://api.github.com/repos/malthe/chameleon/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/malthe/chameleon/issues/246/comments","events_url":"https://api.github.com/repos/malthe/chameleon/issues/246/events","html_url":"https://github.com/malthe/chameleon/issues/246","id":257761751,"number":246,"title":"chameleon does not work if sourcecode is not available","user":{"login":"mrh1997","id":1482077,"avatar_url":"https://avatars0.githubusercontent.com/u/1482077?v=4","gravatar_id":"","url":"https://api.github.com/users/mrh1997","html_url":"https://github.com/mrh1997","followers_url":"https://api.github.com/users/mrh1997/followers","following_url":"https://api.github.com/users/mrh1997/following{/other_user}","gists_url":"https://api.github.com/users/mrh1997/gists{/gist_id}","starred_url":"https://api.github.com/users/mrh1997/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrh1997/subscriptions","organizations_url":"https://api.github.com/users/mrh1997/orgs","repos_url":"https://api.github.com/users/mrh1997/repos","events_url":"https://api.github.com/users/mrh1997/events{/privacy}","received_events_url":"https://api.github.com/users/mrh1997/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-14T15:29:09Z","updated_at":"2017-09-14T15:29:09Z","closed_at":null,"author_association":"NONE","body":"On systems where only .pyc files were delivered (.py sources are not available) chameleon does not work. This is i.e. the case when I try to pack a project via [cx_freeze](https://anthony-tuininga.github.io/cx_Freeze/) or similar deployment tool (the bug is already reported [here](https://sourceforge.net/p/cx-freeze/mailman/message/29779171/).\r\n\r\nThe reason is that the `codegen.template()` when used as decorator tries to get the source code of a decorated function and translates it into an AST. Currently template() is mainly used to enclose strings which does not cause problems. But in `compiler.py` there are 7 deorated functions (starting with emit*()) that cannot be processed without the sourcecode.\r\n\r\nMy proposal: instead of using tempate as decorator for functions we could use it as regular function with string parameter:\r\n\r\n```\r\n@template\r\ndef emit_node(node):  # pragma: no cover\r\n    __append(node)\r\n```\r\n\r\nwould become:\r\n\r\n```\r\nemit_node = template(\"__append(node)\", params=['node'])\r\n```\r\n\r\nThe disadvantage would be, that when debugging you cannot step through the function body of emit_node any more. But on the pro side there is less magic that can cause problems. If you agree with my proposal I could do a fix..."}}
{"actor":{"display_login":"mrh1997"}}