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

Tidy up, and add harness for examples #27

Merged
merged 4 commits into from Jan 13, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Update the xml and htmlparser examples to work on Python 2.

Some simple checks for the behaviour of the modules under Python
2 compared to Python 3.
  • Loading branch information
gerph committed Jan 11, 2020
commit 5e2a05e0ba0f3b7f4e574b09271edfc96ddd9d6b
@@ -1,4 +1,8 @@
from html.parser import HTMLParser
try:
from html.parser import HTMLParser
except ImportError:
from HTMLParser import HTMLParser

from pythonfuzz.main import PythonFuzz


@@ -1,12 +1,19 @@
import xml.etree.ElementTree as ET
from xml.etree.ElementTree import ParseError
import sys

from pythonfuzz.main import PythonFuzz


@PythonFuzz
def fuzz(buf):
try:
string = buf.decode("utf-8")
# In Python 2, the ElementTree only consumes bytes, not unicode strings,
# so we need to supply the correct format depending on the python version.
if sys.version_info[0] == 2:
string = bytes(buf)
else:
string = buf.decode("utf-8")
ET.fromstring(string)
except (UnicodeDecodeError, ParseError):
pass
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.