Skip to content

Commit 0612ec4

Browse files
committed
Fixing Python3 compatibility
1 parent 77ad77e commit 0612ec4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

bootstrap3/utils.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
from __future__ import unicode_literals
33

44
import re
5-
from urllib import urlencode
6-
from urlparse import urlparse, parse_qs, urlunparse
5+
6+
try:
7+
from urllib import urlencode
8+
except ImportError:
9+
from urllib.parse import urlencode
10+
11+
try:
12+
from urlparse import urlparse, parse_qs, urlunparse
13+
except ImportError:
14+
from urllib.parse import urlparse, parse_qs, urlunparse
715

816
from django.forms.widgets import flatatt
917
from django.template import Variable, VariableDoesNotExist
@@ -156,4 +164,4 @@ def url_replace_param(url, name, value):
156164
url_components.params,
157165
query,
158166
url_components.fragment,
159-
])
167+
])

0 commit comments

Comments
 (0)