{"action":"closed","issue":{"url":"https://api.github.com/repos/ppwwyyxx/tensorpack/issues/756","repository_url":"https://api.github.com/repos/ppwwyyxx/tensorpack","labels_url":"https://api.github.com/repos/ppwwyyxx/tensorpack/issues/756/labels{/name}","comments_url":"https://api.github.com/repos/ppwwyyxx/tensorpack/issues/756/comments","events_url":"https://api.github.com/repos/ppwwyyxx/tensorpack/issues/756/events","html_url":"https://github.com/ppwwyyxx/tensorpack/issues/756","id":321736602,"number":756,"title":"KerasModelCaller: \"UnboundLocalError: local variable 'M' referenced before assignment\"","user":{"login":"bzamecnik","id":446124,"avatar_url":"https://avatars1.githubusercontent.com/u/446124?v=4","gravatar_id":"","url":"https://api.github.com/users/bzamecnik","html_url":"https://github.com/bzamecnik","followers_url":"https://api.github.com/users/bzamecnik/followers","following_url":"https://api.github.com/users/bzamecnik/following{/other_user}","gists_url":"https://api.github.com/users/bzamecnik/gists{/gist_id}","starred_url":"https://api.github.com/users/bzamecnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bzamecnik/subscriptions","organizations_url":"https://api.github.com/users/bzamecnik/orgs","repos_url":"https://api.github.com/users/bzamecnik/repos","events_url":"https://api.github.com/users/bzamecnik/events{/privacy}","received_events_url":"https://api.github.com/users/bzamecnik/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-09T21:42:14Z","updated_at":"2018-05-09T22:03:12Z","closed_at":"2018-05-09T22:03:12Z","author_association":"CONTRIBUTOR","body":"In `tensorpack.keras.KerasModelCaller` there's a `try-finally` statement and in the `finally` block a local variable `M` representing `KerasModel` is referenced even though an exception might occur which prevented assigning it. Anyway the whole block of code seems very strange and a misuse of this language construct.\r\n\r\nIf I understand the intention, we want to return model outputs but call some procedure on the model in all cases. Why can't we just refactor it to a function and call it at the end?"}}
{"actor":{"display_login":"ppwwyyxx"}}