{"action":"created","issue":{"url":"https://api.github.com/repos/google/yapf/issues/32","labels_url":"https://api.github.com/repos/google/yapf/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/google/yapf/issues/32/comments","events_url":"https://api.github.com/repos/google/yapf/issues/32/events","html_url":"https://github.com/google/yapf/issues/32","id":64574456,"number":32,"title":"lib2to3 parse error on well formed code that 2to3 passes fine","user":{"login":"DRMacIver","id":28623,"avatar_url":"https://avatars.githubusercontent.com/u/28623?v=3","gravatar_id":"","url":"https://api.github.com/users/DRMacIver","html_url":"https://github.com/DRMacIver","followers_url":"https://api.github.com/users/DRMacIver/followers","following_url":"https://api.github.com/users/DRMacIver/following{/other_user}","gists_url":"https://api.github.com/users/DRMacIver/gists{/gist_id}","starred_url":"https://api.github.com/users/DRMacIver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DRMacIver/subscriptions","organizations_url":"https://api.github.com/users/DRMacIver/orgs","repos_url":"https://api.github.com/users/DRMacIver/repos","events_url":"https://api.github.com/users/DRMacIver/events{/privacy}","received_events_url":"https://api.github.com/users/DRMacIver/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-26T16:33:31Z","updated_at":"2015-03-26T21:44:52Z","closed_at":null,"body":"The following code:\r\n\r\n    def response(                  using=None):\r\n        if (context_instance is _context_instance_undefined and\r\n            dirs is _dirs_undefined and dictionary is _dictionary_undefined):\r\n                return to\r\n\r\nGives me the following exception when run under python 3.4:\r\n\r\n    Traceback (most recent call last):\r\n      File \"/home/david/yapf/yapf/yapflib/pytree_utils.py\", line 85, in ParseCodeToTree\r\n        tree = parser_driver.parse_string(code, debug=False)\r\n      File \"/home/david/.pyenv/versions/3.4.2/lib/python3.4/lib2to3/pgen2/driver.py\", line 106, in parse_string\r\n        return self.parse_tokens(tokens, debug)\r\n      File \"/home/david/.pyenv/versions/3.4.2/lib/python3.4/lib2to3/pgen2/driver.py\", line 71, in parse_tokens\r\n        if p.addtoken(type, value, (prefix, start)):\r\n      File \"/home/david/.pyenv/versions/3.4.2/lib/python3.4/lib2to3/pgen2/parse.py\", line 159, in addtoken\r\n        raise ParseError(\"bad input\", type, value, context)\r\n    lib2to3.pgen2.parse.ParseError: bad input: type=6, value='', context=('\\n', (5, 0))\r\n\r\n    During handling of the above exception, another exception occurred:\r\n\r\n    Traceback (most recent call last):\r\n      File \"/home/david/.pyenv/versions/3.4.2/lib/python3.4/runpy.py\", line 170, in _run_module_as_main\r\n        \"__main__\", mod_spec)\r\n      File \"/home/david/.pyenv/versions/3.4.2/lib/python3.4/runpy.py\", line 85, in _run_code\r\n        exec(code, run_globals)\r\n      File \"/home/david/yapf/yapf/__main__.py\", line 18, in <module>\r\n        sys.exit(yapf.main(sys.argv))\r\n      File \"/home/david/yapf/yapf/__init__.py\", line 102, in main\r\n        print_diff=args.diff)\r\n      File \"/home/david/yapf/yapf/__init__.py\", line 124, in FormatFiles\r\n        filename, style_config=style_config, lines=lines, print_diff=print_diff)\r\n      File \"/home/david/yapf/yapf/yapflib/yapf_api.py\", line 67, in FormatFile\r\n        print_diff=print_diff)\r\n      File \"/home/david/yapf/yapf/yapflib/yapf_api.py\", line 88, in FormatCode\r\n        tree = pytree_utils.ParseCodeToTree(unformatted_source)\r\n      File \"/home/david/yapf/yapf/yapflib/pytree_utils.py\", line 91, in ParseCodeToTree\r\n        tree = parser_driver.parse_string(code, debug=False)\r\n      File \"/home/david/.pyenv/versions/3.4.2/lib/python3.4/lib2to3/pgen2/driver.py\", line 106, in parse_string\r\n        return self.parse_tokens(tokens, debug)\r\n      File \"/home/david/.pyenv/versions/3.4.2/lib/python3.4/lib2to3/pgen2/driver.py\", line 71, in parse_tokens\r\n        if p.addtoken(type, value, (prefix, start)):\r\n      File \"/home/david/.pyenv/versions/3.4.2/lib/python3.4/lib2to3/pgen2/parse.py\", line 159, in addtoken\r\n        raise ParseError(\"bad input\", type, value, context)\r\n    lib2to3.pgen2.parse.ParseError: bad input: type=6, value='', context=('\\n', (5, 0))\r\n\r\n\r\nRunning the normal 2to3 command line utility on this file works fine, so I think there's something about what you're passing in to 2to3."},"comment":{"url":"https://api.github.com/repos/google/yapf/issues/comments/86729983","html_url":"https://github.com/google/yapf/issues/32#issuecomment-86729983","issue_url":"https://api.github.com/repos/google/yapf/issues/32","id":86729983,"user":{"login":"DRMacIver","id":28623,"avatar_url":"https://avatars.githubusercontent.com/u/28623?v=3","gravatar_id":"","url":"https://api.github.com/users/DRMacIver","html_url":"https://github.com/DRMacIver","followers_url":"https://api.github.com/users/DRMacIver/followers","following_url":"https://api.github.com/users/DRMacIver/following{/other_user}","gists_url":"https://api.github.com/users/DRMacIver/gists{/gist_id}","starred_url":"https://api.github.com/users/DRMacIver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DRMacIver/subscriptions","organizations_url":"https://api.github.com/users/DRMacIver/orgs","repos_url":"https://api.github.com/users/DRMacIver/repos","events_url":"https://api.github.com/users/DRMacIver/events{/privacy}","received_events_url":"https://api.github.com/users/DRMacIver/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T21:44:52Z","updated_at":"2015-03-26T21:44:52Z","body":"Ah! I understand what's going on now.\r\n\r\nYou will get this error if you try to format a file where the last character of the file is not whitespace. This will probably mean that you can't reproduce any of the above by copying and pasting them."}}