[New-bugs-announce] [issue35968] lib2to3 cannot parse rf''

Dylan Lloyd report at bugs.python.org
Mon Feb 11 11:39:57 EST 2019


New submission from Dylan Lloyd <dylan at disinclined.org>:

```
#!/usr/bin/env python
# -*- coding: utf-8 -*-

regex_format = rf''
```

```
yapf poc.py
```

```
Traceback (most recent call last):
  File "lib/python3.6/site-packages/yapf/yapflib/pytree_utils.py", line 115, in ParseCodeToTree
    tree = parser_driver.parse_string(code, debug=False)
  File "lib/python3.6/lib2to3/pgen2/driver.py", line 107, in parse_string
    return self.parse_tokens(tokens, debug)
  File "lib/python3.6/lib2to3/pgen2/driver.py", line 72, in parse_tokens
    if p.addtoken(type, value, (prefix, start)):
  File "lib/python3.6/lib2to3/pgen2/parse.py", line 159, in addtoken
    raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=3, value="''", context=('', (4, 17))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bin/yapf", line 10, in <module>
    sys.exit(run_main())
  File "lib/python3.6/site-packages/yapf/__init__.py", line 326, in run_main
    sys.exit(main(sys.argv))
  File "lib/python3.6/site-packages/yapf/__init__.py", line 213, in main
    verbose=args.verbose)
  File "lib/python3.6/site-packages/yapf/__init__.py", line 263, in FormatFiles
    in_place, print_diff, verify, verbose)
  File "lib/python3.6/site-packages/yapf/__init__.py", line 289, in _FormatFile
    logger=logging.warning)
  File "lib/python3.6/site-packages/yapf/yapflib/yapf_api.py", line 91, in FormatFile
    verify=verify)
  File "lib/python3.6/site-packages/yapf/yapflib/yapf_api.py", line 129, in FormatCode
    tree = pytree_utils.ParseCodeToTree(unformatted_source)
  File "lib/python3.6/site-packages/yapf/yapflib/pytree_utils.py", line 121, in ParseCodeToTree
    tree = parser_driver.parse_string(code, debug=False)
  File "lib/python3.6/lib2to3/pgen2/driver.py", line 107, in parse_string
    return self.parse_tokens(tokens, debug)
  File "lib/python3.6/lib2to3/pgen2/driver.py", line 72, in parse_tokens
    if p.addtoken(type, value, (prefix, start)):
  File "lib/python3.6/lib2to3/pgen2/parse.py", line 159, in addtoken
    raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=3, value="''", context=('', (4, 17))
```

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 335238
nosy: majuscule
priority: normal
severity: normal
status: open
title: lib2to3 cannot parse rf''
type: crash
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35968>
_______________________________________


More information about the New-bugs-announce mailing list