summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-03-27 08:08:42 -0400
committerTim Graham <timograham@gmail.com>2014-03-27 09:17:49 -0400
commitdadf2ee75f88653b94b9c05a3118fd1590853e77 (patch)
treec469227ec8e80ef4fc9d902deca16c72a4cdd8a9
parent306deab2c70a6d93c6188924e1cfa8c2d50ccd48 (diff)
Fixed a deprecation warning with the HTMLParser safe argument.
refs 6ca6c36f82b97eafeada61384b2e2f1d0587da86
-rw-r--r--django/utils/html.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index d0ae23b77f..bf4fb02c3d 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -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
@@ -118,10 +119,12 @@ linebreaks = allow_lazy(linebreaks, six.text_type)
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 = []