Skip to content

Commit

Permalink
Fixed a deprecation warning with the HTMLParser safe argument.
Browse files Browse the repository at this point in the history
refs 6ca6c36
  • Loading branch information
timgraham committed Mar 27, 2014
1 parent 306deab commit dadf2ee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions django/utils/html.py
Expand Up @@ -3,6 +3,7 @@
from __future__ import unicode_literals

import re
import sys

from django.utils.encoding import force_text, force_str
from django.utils.functional import allow_lazy
Expand Down Expand Up @@ -118,10 +119,12 @@ def linebreaks(value, autoescape=False):

class MLStripper(HTMLParser):
def __init__(self):
if six.PY2:
HTMLParser.__init__(self)
else:
# The strict parameter was added in Python 3.2 with a default of True.
# The default changed to False in Python 3.3 and was deprecated.
if sys.version_info[:2] == (3, 2):
HTMLParser.__init__(self, strict=False)
else:
HTMLParser.__init__(self)
self.reset()
self.fed = []

Expand Down

0 comments on commit dadf2ee

Please sign in to comment.