|
1 | | -# Copyright The IETF Trust 2012-2019, All Rights Reserved |
| 1 | +# Copyright The IETF Trust 2012-2020, All Rights Reserved |
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 |
|
4 | 4 |
|
|
13 | 13 | from six.moves.urllib.request import Request, urlopen |
14 | 14 |
|
15 | 15 | from django.conf import settings |
16 | | -from django.utils.encoding import force_str |
| 16 | +from django.utils.encoding import smart_bytes, force_str |
17 | 17 | from django.utils.http import urlquote |
18 | 18 |
|
19 | 19 | import debug # pyflakes:ignore |
|
31 | 31 |
|
32 | 32 | def fetch_protocol_page(url): |
33 | 33 | f = urlopen(settings.IANA_SYNC_PROTOCOLS_URL) |
34 | | - text = f.read() |
| 34 | + text = force_str(f.read()) |
35 | 35 | f.close() |
36 | 36 | return text |
37 | 37 |
|
38 | 38 | def parse_protocol_page(text): |
39 | 39 | """Parse IANA protocols page to extract referenced RFCs (as |
40 | 40 | rfcXXXX document names).""" |
41 | | - matches = re.findall('RFC [0-9]+', text) |
| 41 | + matches = re.findall('RFC [0-9]+', force_str(text)) |
42 | 42 | res = set() |
43 | 43 | for m in matches: |
44 | 44 | res.add("rfc" + m[len("RFC "):]) |
@@ -78,7 +78,7 @@ def fetch_changes_json(url, start, end): |
78 | 78 | # HTTP basic auth |
79 | 79 | username = "ietfsync" |
80 | 80 | password = settings.IANA_SYNC_PASSWORD |
81 | | - request.add_header("Authorization", "Basic %s" % base64.encodestring("%s:%s" % (username, password)).replace("\n", "")) |
| 81 | + request.add_header("Authorization", "Basic %s" % force_str(base64.encodestring(smart_bytes("%s:%s" % (username, password)))).replace("\n", "")) |
82 | 82 | f = urlopen(request) |
83 | 83 | text = f.read() |
84 | 84 | f.close() |
|
0 commit comments