Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error found with Hypothesmith #970

Open
Zac-HD opened this issue Aug 7, 2019 · 2 comments
Open

Parse error found with Hypothesmith #970

Zac-HD opened this issue Aug 7, 2019 · 2 comments
Labels
C: crash Black is crashing C: parser How we parse code. Or fail to parse it. T: bug Something isn't working

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented Aug 7, 2019

weird = "pass #\r#\n"
exec(weird)                                     # works, as does `compile` etc.
black.format_str(weird, mode=black.FileMode())  # fails with `black.InvalidInput`

Operating system: Windows
Python version: 3.7.3
Black version: 19.3b0
Does also happen on master: yes (website hangs)

I found this weird little string with hypothesmith, a tool for generating Python source code with Hypothesis that I started at the PyCon NA sprints and published at the PyCon AU sprints. Currently it works based on an approximate grammar, post-processing, and filtering.

CC @ambv who I know was interested in fuzzing 😄. Next steps... I think a combination of targeted mutation (open PR upstream) and spending more than a few minutes of CPU time could turn up a lot more weird things!

@zsol
Copy link
Collaborator

zsol commented Aug 7, 2019

Nice!

@zsol zsol added T: bug Something isn't working lib2to3 labels Aug 7, 2019
@zsol
Copy link
Collaborator

zsol commented Aug 7, 2019

FWIW this is also a bug in upstream lib2to3. You might want to report it on http://bugs.python.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: crash Black is crashing C: parser How we parse code. Or fail to parse it. T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants