Merge lp:~stefanor/beautifulsoup/python3.4 into lp:beautifulsoup

Proposed by Stefano Rivera
Status: Merged
Merge reported by: Leonard Richardson
Merged at revision: not available
Proposed branch: lp:~stefanor/beautifulsoup/python3.4
Merge into: lp:beautifulsoup
Diff against target: 34 lines (+5/-5)
1 file modified
bs4/builder/_htmlparser.py (+5/-5)
To merge this branch: bzr merge lp:~stefanor/beautifulsoup/python3.4
Reviewer Review Type Date Requested Status
Leonard Richardson Pending
Review via email: mp+238642@code.launchpad.net

Description of the change

Handle the new warnings in Python 3.4, that cause LP: #1375721.

This fixes the bug.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bs4/builder/_htmlparser.py'
--- bs4/builder/_htmlparser.py 2013-10-02 01:55:22 +0000
+++ bs4/builder/_htmlparser.py 2014-10-17 01:55:41 +0000
@@ -19,10 +19,8 @@
19# At the end of this file, we monkeypatch HTMLParser so that19# At the end of this file, we monkeypatch HTMLParser so that
20# strict=True works well on Python 3.2.2.20# strict=True works well on Python 3.2.2.
21major, minor, release = sys.version_info[:3]21major, minor, release = sys.version_info[:3]
22CONSTRUCTOR_TAKES_STRICT = (22CONSTRUCTOR_TAKES_STRICT = major == 3 and minor == 2 and release >= 3
23 major > 323CONSTRUCTOR_TAKES_CONVERT_CHARREFS = major == 3 and minor >= 4
24 or (major == 3 and minor > 2)
25 or (major == 3 and minor == 2 and release >= 3))
2624
27from bs4.element import (25from bs4.element import (
28 CData,26 CData,
@@ -63,7 +61,7 @@
6361
64 def handle_charref(self, name):62 def handle_charref(self, name):
65 # XXX workaround for a bug in HTMLParser. Remove this once63 # XXX workaround for a bug in HTMLParser. Remove this once
66 # it's fixed.64 # it's fixed. http://bugs.python.org/issue13633
67 if name.startswith('x'):65 if name.startswith('x'):
68 real_name = int(name.lstrip('x'), 16)66 real_name = int(name.lstrip('x'), 16)
69 elif name.startswith('X'):67 elif name.startswith('X'):
@@ -133,6 +131,8 @@
133 def __init__(self, *args, **kwargs):131 def __init__(self, *args, **kwargs):
134 if CONSTRUCTOR_TAKES_STRICT:132 if CONSTRUCTOR_TAKES_STRICT:
135 kwargs['strict'] = False133 kwargs['strict'] = False
134 if CONSTRUCTOR_TAKES_CONVERT_CHARREFS:
135 kwargs['convert_charrefs'] = False
136 self.parser_args = (args, kwargs)136 self.parser_args = (args, kwargs)
137137
138 def prepare_markup(self, markup, user_specified_encoding=None,138 def prepare_markup(self, markup, user_specified_encoding=None,

Subscribers

People subscribed via source and target branches

to status/vote changes: