Skip to content

Commit 88900e0

Browse files
Cosimo LupoGauvain Pocentek
Cosimo Lupo
authored and
Gauvain Pocentek
committed
import urlencode() from six.moves.urllib.parse instead of from urllib (#268)
Fixes AttributeError on Python 3, as `urlencode` function has been moved to `urllib.parse` module. `six.moves.urllib.parse.urlencode()` is an py2.py3 compatible alias of `urllib.parse.urlencode()` on Python 3, and of `urllib.urlencode()` on Python 2.
1 parent 38bff3e commit 88900e0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

gitlab/v3/objects.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
from __future__ import absolute_import
2121
import base64
2222
import json
23-
import urllib
2423
import warnings
2524

2625
import six
26+
from six.moves import urllib
2727

2828
import gitlab
2929
from gitlab.base import * # noqa
@@ -1841,7 +1841,7 @@ def repository_tree(self, path='', ref_name='', **kwargs):
18411841
url = "/projects/%s/repository/tree" % (self.id)
18421842
params = []
18431843
if path:
1844-
params.append(urllib.urlencode({'path': path}))
1844+
params.append(urllib.parse.urlencode({'path': path}))
18451845
if ref_name:
18461846
params.append("ref_name=%s" % ref_name)
18471847
if params:
@@ -1872,7 +1872,7 @@ def repository_blob(self, sha, filepath, streamed=False, action=None,
18721872
GitlabGetError: If the server fails to perform the request.
18731873
"""
18741874
url = "/projects/%s/repository/blobs/%s" % (self.id, sha)
1875-
url += '?%s' % (urllib.urlencode({'filepath': filepath}))
1875+
url += '?%s' % (urllib.parse.urlencode({'filepath': filepath}))
18761876
r = self.gitlab._raw_get(url, streamed=streamed, **kwargs)
18771877
raise_error_from_response(r, GitlabGetError)
18781878
return utils.response_content(r, streamed, action, chunk_size)

gitlab/v4/objects.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
from __future__ import absolute_import
2121
import base64
2222
import json
23-
import urllib
2423

2524
import six
25+
from six.moves import urllib
2626

2727
import gitlab
2828
from gitlab.base import * # noqa
@@ -1846,7 +1846,7 @@ def repository_tree(self, path='', ref='', **kwargs):
18461846
url = "/projects/%s/repository/tree" % (self.id)
18471847
params = []
18481848
if path:
1849-
params.append(urllib.urlencode({'path': path}))
1849+
params.append(urllib.parse.urlencode({'path': path}))
18501850
if ref:
18511851
params.append("ref=%s" % ref)
18521852
if params:

0 commit comments

Comments
 (0)