deezer / html-linter

HTML5 Linter based on Google Style Guide
Apache License 2.0
51 stars 13 forks source link

Linter fails in Python 3.5.0 #8

Open ResidentMario opened 8 years ago

ResidentMario commented 8 years ago

Unfortunately html_linter does not currently work with Python 3.5, returning the following error:

(mysite)Honorss-Air-2:templates Honors$ html_lint.py this_website.html
Traceback (most recent call last):
  File "/Users/Honors/Desktop/mysite/bin/html_lint.py", line 119, in <module>
    sys.exit(main())
  File "/Users/Honors/Desktop/mysite/bin/html_lint.py", line 109, in main
    results = html_linter.lint(clean_html, exclude=exclude)
  File "/Users/Honors/Desktop/mysite/lib/python3.5/site-packages/html_linter.py", line 1024, in lint
    messages = [m.__unicode__() for m in HTML5Linter(html).messages
  File "/Users/Honors/Desktop/mysite/lib/python3.5/site-packages/html_linter.py", line 529, in __init__
    self.feed(html)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/html/parser.py", line 111, in feed
    self.goahead(0)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/html/parser.py", line 163, in goahead
    k = self.parse_starttag(i)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/html/parser.py", line 337, in parse_starttag
    self.handle_starttag(tag, attrs)
  File "/Users/Honors/Desktop/mysite/lib/python3.5/site-packages/html_linter.py", line 617, in handle_starttag
    self._check_attributes_case_quotation_entities(tag, attrs)
  File "/Users/Honors/Desktop/mysite/lib/python3.5/site-packages/html_linter.py", line 800, in _check_attributes_case_quotation_entities
    for match in HTMLParser.attrfind.finditer(original_def, len(tag) + 1):
AttributeError: module 'html.parser' has no attribute 'attrfind'

A quick Google search for the nature of this problem brought up this blog post, which seems to point to HTMLParseError having been deprecated in Python 3.5.0.

This commit was pushed to fix this issue for Django. My project uses Flask, though.

Hope to see this get fixed! In the meantime I am using online HTML validators and fixing post-facto, which is inelegant; for the meantime, does anyone know of a good workaround?

sk- commented 8 years ago

This was fixed in my fork, which is now the active one. https://github.com/sk-/html-linter/pull/4.

I will update the package on pypi in a few minutes.

sils commented 8 years ago

hi, forgot the update?

sk- commented 8 years ago

Hi, the update should be there. It's version 0.2. I need to update the readme to specify that 3.5 is supported. But the package metadata already says so.

Did you grab the latest pypi version and checked the code is different than the one in github? Let me know. I will be on mobile only until next Monday. On Jan 6, 2016 11:40 AM, "Lasse Schuirmann" notifications@github.com wrote:

hi, forgot the update?

— Reply to this email directly or view it on GitHub https://github.com/deezer/html-linter/issues/8#issuecomment-169340023.