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
1=== modified file 'bs4/builder/_htmlparser.py'
2--- bs4/builder/_htmlparser.py 2013-10-02 01:55:22 +0000
3+++ bs4/builder/_htmlparser.py 2014-10-17 01:55:41 +0000
4@@ -19,10 +19,8 @@
5 # At the end of this file, we monkeypatch HTMLParser so that
6 # strict=True works well on Python 3.2.2.
7 major, minor, release = sys.version_info[:3]
8-CONSTRUCTOR_TAKES_STRICT = (
9- major > 3
10- or (major == 3 and minor > 2)
11- or (major == 3 and minor == 2 and release >= 3))
12+CONSTRUCTOR_TAKES_STRICT = major == 3 and minor == 2 and release >= 3
13+CONSTRUCTOR_TAKES_CONVERT_CHARREFS = major == 3 and minor >= 4
14
15 from bs4.element import (
16 CData,
17@@ -63,7 +61,7 @@
18
19 def handle_charref(self, name):
20 # XXX workaround for a bug in HTMLParser. Remove this once
21- # it's fixed.
22+ # it's fixed. http://bugs.python.org/issue13633
23 if name.startswith('x'):
24 real_name = int(name.lstrip('x'), 16)
25 elif name.startswith('X'):
26@@ -133,6 +131,8 @@
27 def __init__(self, *args, **kwargs):
28 if CONSTRUCTOR_TAKES_STRICT:
29 kwargs['strict'] = False
30+ if CONSTRUCTOR_TAKES_CONVERT_CHARREFS:
31+ kwargs['convert_charrefs'] = False
32 self.parser_args = (args, kwargs)
33
34 def prepare_markup(self, markup, user_specified_encoding=None,

Subscribers

People subscribed via source and target branches

to status/vote changes: