Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Fix two deprecation warnings (#6439)
Browse files Browse the repository at this point in the history
- The HTMLParser.unescape() method is a deprecated alias for html.unescape()
- base64.encodestring() is a deprecated alias for .encodebytes()
  • Loading branch information
callahad committed Feb 10, 2020
1 parent 37b5907 commit 5c5646f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions kuma/core/templatetags/jinja_helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


import datetime
import html
import json
from html.parser import HTMLParser

import jinja2
from django.conf import settings
Expand All @@ -24,9 +24,6 @@
urlparams)


htmlparser = HTMLParser()


# Yanking filters from Django.
library.filter(defaultfilters.escapejs)
library.filter(defaultfilters.linebreaksbr)
Expand Down Expand Up @@ -108,7 +105,7 @@ def yesno(boolean_value):
@library.filter
def entity_decode(str):
"""Turn HTML entities in a string into unicode."""
return htmlparser.unescape(str)
return html.unescape(str)


@library.global_function
Expand Down
2 changes: 1 addition & 1 deletion kuma/wiki/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def ks_toolbox():
}

d_json = json.dumps(errors)
d_b64 = base64.encodestring(d_json.encode()).decode()
d_b64 = base64.encodebytes(d_json.encode()).decode()
d_lines = [x for x in d_b64.split('\n') if x]

# Headers are case-insensitive, so let's drive that point home.
Expand Down
4 changes: 2 additions & 2 deletions kuma/wiki/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


import datetime
import html
import json
from html.parser import HTMLParser
from unittest import mock
from urllib.parse import parse_qs, urlencode, urlparse

Expand Down Expand Up @@ -1474,7 +1474,7 @@ def test_edit_midair_collisions(self, is_ajax=False, translate_locale=None):
# Add an some extra characters to the end, since the unescaped length
# is a little less than the escaped length
end_of_error = start_of_error + len(collision_err) + 20
location_of_error = HTMLParser().unescape(
location_of_error = html.unescape(
content[start_of_error: end_of_error]
)
assert collision_err in location_of_error
Expand Down

0 comments on commit 5c5646f

Please sign in to comment.