Skip to content

Commit

Permalink
import urlencode() from six.moves.urllib.parse instead of from urllib (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
Cosimo Lupo authored and Gauvain Pocentek committed Jun 2, 2017
1 parent 38bff3e commit 88900e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions gitlab/v3/objects.py
Expand Up @@ -20,10 +20,10 @@
from __future__ import absolute_import
import base64
import json
import urllib
import warnings

import six
from six.moves import urllib

import gitlab
from gitlab.base import * # noqa
Expand Down Expand Up @@ -1841,7 +1841,7 @@ def repository_tree(self, path='', ref_name='', **kwargs):
url = "/projects/%s/repository/tree" % (self.id)
params = []
if path:
params.append(urllib.urlencode({'path': path}))
params.append(urllib.parse.urlencode({'path': path}))
if ref_name:
params.append("ref_name=%s" % ref_name)
if params:
Expand Down Expand Up @@ -1872,7 +1872,7 @@ def repository_blob(self, sha, filepath, streamed=False, action=None,
GitlabGetError: If the server fails to perform the request.
"""
url = "/projects/%s/repository/blobs/%s" % (self.id, sha)
url += '?%s' % (urllib.urlencode({'filepath': filepath}))
url += '?%s' % (urllib.parse.urlencode({'filepath': filepath}))
r = self.gitlab._raw_get(url, streamed=streamed, **kwargs)
raise_error_from_response(r, GitlabGetError)
return utils.response_content(r, streamed, action, chunk_size)
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/objects.py
Expand Up @@ -20,9 +20,9 @@
from __future__ import absolute_import
import base64
import json
import urllib

import six
from six.moves import urllib

import gitlab
from gitlab.base import * # noqa
Expand Down Expand Up @@ -1846,7 +1846,7 @@ def repository_tree(self, path='', ref='', **kwargs):
url = "/projects/%s/repository/tree" % (self.id)
params = []
if path:
params.append(urllib.urlencode({'path': path}))
params.append(urllib.parse.urlencode({'path': path}))
if ref:
params.append("ref=%s" % ref)
if params:
Expand Down

0 comments on commit 88900e0

Please sign in to comment.