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

UnicodeDecodeError: 'ascii' codec can't decode byte 0xcb in position 2542: ordinal not in range(128) #40

Closed
9 tasks
docfate111 opened this issue Mar 29, 2020 · 4 comments · Fixed by #41
Closed
9 tasks
Assignees
Labels
bug needs-triage A fresh user-reported issue that needs triage (i.e. is not a concrete-issue)

Comments

@docfate111
Copy link

docfate111 commented Mar 29, 2020

After creating the issue, checkboxes will appear where [] label exist in the
markdown. You can check/uncheck them to fill out the environment section.

Checklist

  • [ x ] I have included the [relevant portions of the] grammar used that caused the bug
  • [ x ] I have filled out the environment section

Environment

Platform

  • Windows
  • Mac
  • [ x ] Linux
  • Other (please specify)

Python Version

  • Python 2.7
  • Python 3.4
  • Python 3.5
  • [ x ] Python 3.6
  • Python 3.7
  • Python 3.8
  • Other (please specify)

Describe the bug

A clear and concise description of what the bug is.
The file isn't opened with the encoding='utf-8' flag so I end with this error when I run main.py https://github.com/mgree/smoosh-fuzz/blob/master/src/posix/main.py in ubuntu docker python3

  File "main.py", line 4, in <module>
    fuzzer.load_grammar('words.py')
  File "/usr/local/lib/python3.6/dist-packages/gramfuzz/__init__.py", line 125, in load_grammar
    data = f.read()
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcb in position 2542: ordinal not in range(128)

To Reproduce

The issue is in the function load_grammar in class GramFuzzer:
--->here: with open(path, "r", WE NEED: encoding='utf-8') as f:
data = f.read()
code = compile(data, path, "exec")
Steps to reproduce

Expected Behavior

I expected the behavior to be the same as in Python3.7 on Mac- a grammar is generated and strings from that grammar.
A clear and concise description of what you expected to happen.

@docfate111 docfate111 added bug needs-triage A fresh user-reported issue that needs triage (i.e. is not a concrete-issue) labels Mar 29, 2020
@d0c-s4vage
Copy link
Owner

Oof, thanks for this! I'll take a look this week

@docfate111
Copy link
Author

May I have permission to git push please?
The solution is just 1 line of code that I wrote above.

@docfate111
Copy link
Author

the line is 124 in init.py
with open(path, "r")as f:
to
with open(path, "r", encoding='utf-8') as f:
otherwise this breaks on Linux

@d0c-s4vage
Copy link
Owner

@docfate111 Thanks for being patient on this! Things have been up in the air lately...

May I have permission to git push please?

PRs are definitely welcome! You can fork the repository, create a new branch in your forked repository, and then submit a new PR from your branch into this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage A fresh user-reported issue that needs triage (i.e. is not a concrete-issue)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants