Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nope.

  Traceback (most recent call last):
    File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
      "__main__", fname, loader, pkg_name)
    File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
      exec code in run_globals
    File "/tmp/yapf/yapf/__main__.py", line 18, in <module>
      sys.exit(yapf.main(sys.argv))
    File "/tmp/yapf/yapf/__init__.py", line 104, in main
      verify=args.verify))
    File "/tmp/yapf/yapf/yapflib/yapf_api.py", line 99, in FormatCode
      tree = pytree_utils.ParseCodeToTree(unformatted_source.rstrip() + '\n')
    File "/tmp/yapf/yapf/yapflib/pytree_utils.py", line 100, in ParseCodeToTree
      tree = parser_driver.parse_string(code, debug=False)
    File "/usr/lib/python2.7/lib2to3/pgen2/driver.py", line 106, in parse_string
      return self.parse_tokens(tokens, debug)
    File "/usr/lib/python2.7/lib2to3/pgen2/driver.py", line 71, in parse_tokens
      if p.addtoken(type, value, (prefix, start)):
    File "/usr/lib/python2.7/lib2to3/pgen2/parse.py", line 116, in addtoken
      ilabel = self.classify(type, value, context)
    File "/usr/lib/python2.7/lib2to3/pgen2/parse.py", line 172, in classify
      raise ParseError("bad token", type, value, context)
  lib2to3.pgen2.parse.ParseError: bad token: type=55, value=u' ', context=('', (1, 5))


Interesting. Can you cite the exact version of Python 2.7 you're using?

Mine is 2.7.6

I'm asking because bugs get fixed in lib2to3 occasionally, and we see differences between minor Python versions in this regard.


Python 2.7.3, the normal one from the current Debian stable.


The time diff between 2.7.3 and 2.7.6 is a year and a half, and lib2to3 got a bunch of fixed merge in during that period. I peeked at the CPython logs, and there's a number of changes so this bug may very well have been plugged.

I guess we should be recommending the latest Python 2.7 possible, since it's very difficult for us to work around lib2to3 bugs in yapf - we're basically limited to whatever it can parse. Some things can be monkey-patched, but core parsing bugs are challenging.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: