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

Linter fails in Python 3.5.0 #8

Open
ResidentMario opened this issue Dec 12, 2015 · 3 comments
Open

Linter fails in Python 3.5.0 #8

ResidentMario opened this issue Dec 12, 2015 · 3 comments

Comments

@ResidentMario
Copy link

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- added a commit to sk-/html-linter that referenced this issue Dec 12, 2015
It replaces the use of attrfind in favor of attrfind_tolerant, as
the former was removed in python 3.5.

Fixes deezer#8.
sk- added a commit to sk-/html-linter that referenced this issue Dec 12, 2015
It replaces the use of attrfind in favor of attrfind_tolerant, as
the former was removed in python 3.5.

Fixes deezer#8.
sk- added a commit to sk-/html-linter that referenced this issue Dec 12, 2015
It replaces the use of attrfind in favor of attrfind_tolerant, as
the former was removed in python 3.5.

Fixes deezer#8.
sk- added a commit to sk-/html-linter that referenced this issue Dec 12, 2015
It replaces the use of attrfind in favor of attrfind_tolerant, as
the former was removed in python 3.5.

For python 2 and pypy, we fallback to attrfind as attrfind_tolerant is not
available.

For python 3.4 and 3.5 we set convert_charrefs to False. Python 3.5
sets its by default to True, which does not allow to introspect their value.

Fixes deezer#8.
@sk-
Copy link

sk- commented Dec 12, 2015

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
Copy link

sils commented Jan 6, 2016

hi, forgot the update?

@sk-
Copy link

sk- commented Jan 7, 2016

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" [email protected]
wrote:

hi, forgot the update?


Reply to this email directly or view it on GitHub
#8 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants