Skip to content

Commit 0f12900

Browse files
authored
Add support for Python 3.12+ where six.moves is not available.
1 parent fd4f032 commit 0f12900

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Diff for: html5lib/_inputstream.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
from __future__ import absolute_import, division, unicode_literals
22

33
from six import text_type
4-
from six.moves import http_client, urllib
4+
5+
try:
6+
from six.moves import http_client, urllib
7+
except ModuleNotFoundError:
8+
# Support for Python 3.12+ where six.moves is not available.
9+
import http.client as http_client
10+
import urllib
511

612
import codecs
713
import re

Diff for: html5lib/filters/sanitizer.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
import warnings
1313
from xml.sax.saxutils import escape, unescape
1414

15-
from six.moves import urllib_parse as urlparse
15+
try:
16+
from six.moves import urllib_parse as urlparse
17+
except ModuleNotFoundError:
18+
# Support for Python 3.12+ where six.moves is not available.
19+
import urllib.parse as urlparse
1620

1721
from . import base
1822
from ..constants import namespaces, prefixes

Diff for: html5lib/tests/test_stream.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
import pytest
1010

1111
import six
12-
from six.moves import http_client, urllib
12+
13+
try:
14+
from six.moves import http_client, urllib
15+
except ModuleNotFoundError:
16+
# Support for Python 3.12+ where six.moves is not available.
17+
import http.client as http_client
18+
import urllib
1319

1420
from html5lib._inputstream import (BufferedStream, HTMLInputStream,
1521
HTMLUnicodeInputStream, HTMLBinaryInputStream)

0 commit comments

Comments
 (0)