# HG changeset patch # User RhodeCode Admin # Date 2023-03-06 22:02:03 # Node ID 5198086f541dcbe7fb148ee956502fcd75272a6c # Parent dbcd47caf60fb4e705ae07ed218251e789243694 python3: fixed urlparse import diff --git a/rhodecode/apps/login/tests/test_login.py b/rhodecode/apps/login/tests/test_login.py --- a/rhodecode/apps/login/tests/test_login.py +++ b/rhodecode/apps/login/tests/test_login.py @@ -18,7 +18,7 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ -import urlparse +import urllib.parse import mock import pytest @@ -147,7 +147,7 @@ class TestLoginController(object): h.route_path('repo_summary', repo_name=HG_REPO, _query=kwargs), status=302) - response_query = urlparse.parse_qsl(response.location) + response_query = urllib.parse.urlparse.parse_qsl(response.location) assert 'branch=stable' in response_query[0][1] def test_login_form_with_get_args(self): diff --git a/rhodecode/apps/login/views.py b/rhodecode/apps/login/views.py --- a/rhodecode/apps/login/views.py +++ b/rhodecode/apps/login/views.py @@ -24,7 +24,7 @@ import datetime import formencode import formencode.htmlfill import logging -import urlparse +import urllib.parse import requests from pyramid.httpexceptions import HTTPFound @@ -90,7 +90,7 @@ def store_user_in_session(session, usern def get_came_from(request): came_from = safe_str(request.GET.get('came_from', '')) - parsed = urlparse.urlparse(came_from) + parsed = urllib.parse.urlparse.urlparse(came_from) allowed_schemes = ['http', 'https'] default_came_from = h.route_path('home') if parsed.scheme and parsed.scheme not in allowed_schemes: diff --git a/rhodecode/apps/ssh_support/lib/backends/svn.py b/rhodecode/apps/ssh_support/lib/backends/svn.py --- a/rhodecode/apps/ssh_support/lib/backends/svn.py +++ b/rhodecode/apps/ssh_support/lib/backends/svn.py @@ -25,7 +25,7 @@ import logging import signal import tempfile from subprocess import Popen, PIPE -import urlparse +import urllib.parse from .base import VcsServer @@ -202,7 +202,7 @@ class SubversionTunnelWrapper(object): if not first_response: return self.fail("Repository name cannot be extracted") - url_parts = urlparse.urlparse(first_response['url']) + url_parts = urllib.parse.urlparse.urlparse(first_response['url']) self.server.repo_name = self._match_repo_name(url_parts.path.strip('/')) diff --git a/rhodecode/lib/markup_renderer.py b/rhodecode/lib/markup_renderer.py --- a/rhodecode/lib/markup_renderer.py +++ b/rhodecode/lib/markup_renderer.py @@ -27,7 +27,7 @@ import re import os import lxml import logging -import urlparse +import urllib.parse import bleach from mako.lookup import TemplateLookup @@ -142,7 +142,7 @@ def relative_path(path, request_path, is # skip data, anchor, invalid links return path - is_absolute = bool(urlparse.urlparse(path).netloc) + is_absolute = bool(urllib.parse.urlparse.urlparse(path).netloc) if is_absolute: return path diff --git a/rhodecode/lib/middleware/simplegit.py b/rhodecode/lib/middleware/simplegit.py --- a/rhodecode/lib/middleware/simplegit.py +++ b/rhodecode/lib/middleware/simplegit.py @@ -25,7 +25,7 @@ It's implemented with basic auth functio import os import re import logging -import urlparse +import urllib.parse import rhodecode from rhodecode.lib import utils @@ -123,7 +123,7 @@ class SimpleGit(simplevcs.SimpleVCS): path = environ['PATH_INFO'] if path.endswith('/info/refs'): - query = urlparse.parse_qs(environ['QUERY_STRING']) + query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING']) service_cmd = query.get('service', [''])[0] return self._ACTION_MAPPING.get(service_cmd, 'pull') diff --git a/rhodecode/lib/middleware/simplehg.py b/rhodecode/lib/middleware/simplehg.py --- a/rhodecode/lib/middleware/simplehg.py +++ b/rhodecode/lib/middleware/simplehg.py @@ -24,7 +24,7 @@ SimpleHG middleware for handling mercuri """ import logging -import urlparse +import urllib.parse import urllib.request, urllib.parse, urllib.error from rhodecode.lib import utils @@ -135,7 +135,7 @@ class SimpleHg(simplevcs.SimpleVCS): :param environ: """ default = 'push' - query = urlparse.parse_qs(environ['QUERY_STRING'], + query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING'], keep_blank_values=True) if 'cmd' in query: diff --git a/rhodecode/lib/middleware/simplesvn.py b/rhodecode/lib/middleware/simplesvn.py --- a/rhodecode/lib/middleware/simplesvn.py +++ b/rhodecode/lib/middleware/simplesvn.py @@ -21,7 +21,7 @@ import base64 import logging import urllib.request, urllib.parse, urllib.error -import urlparse +import urllib.parse import requests from pyramid.httpexceptions import HTTPNotAcceptable @@ -123,7 +123,7 @@ class SimpleSvnApp(object): def _get_url(self, svn_http_server, path): svn_http_server_url = (svn_http_server or '').rstrip('/') - url_path = urlparse.urljoin(svn_http_server_url + '/', (path or '').lstrip('/')) + url_path = urllib.parse.urlparse.urljoin(svn_http_server_url + '/', (path or '').lstrip('/')) url_path = urllib.parse.quote(url_path, safe="/:=~+!$,;'") return url_path diff --git a/rhodecode/lib/middleware/utils/scm_app_http.py b/rhodecode/lib/middleware/utils/scm_app_http.py --- a/rhodecode/lib/middleware/utils/scm_app_http.py +++ b/rhodecode/lib/middleware/utils/scm_app_http.py @@ -24,7 +24,7 @@ Implementation of the scm_app interface import base64 import logging -import urlparse +import urllib.parse import wsgiref.util import msgpack @@ -111,7 +111,7 @@ class VcsHttpProxy(object): # Preserve the query string url = self._url - url = urlparse.urljoin(url, self._repo_name) + url = urllib.parse.urlparse.urljoin(url, self._repo_name) if environ.get('QUERY_STRING'): url += '?' + environ['QUERY_STRING'] diff --git a/rhodecode/lib/middleware/vcs.py b/rhodecode/lib/middleware/vcs.py --- a/rhodecode/lib/middleware/vcs.py +++ b/rhodecode/lib/middleware/vcs.py @@ -22,7 +22,7 @@ import gzip import shutil import logging import tempfile -import urlparse +import urllib.parse from webob.exc import HTTPNotFound @@ -61,7 +61,7 @@ def is_hg(environ): http_accept = environ.get('HTTP_ACCEPT') if http_accept and http_accept.startswith('application/mercurial'): - query = urlparse.parse_qs(environ['QUERY_STRING']) + query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING']) if 'cmd' in query: is_hg_path = True diff --git a/rhodecode/lib/vcs/client_http.py b/rhodecode/lib/vcs/client_http.py --- a/rhodecode/lib/vcs/client_http.py +++ b/rhodecode/lib/vcs/client_http.py @@ -27,7 +27,7 @@ import logging import threading import time import urllib.request, urllib.error, urllib.parse -import urlparse +import urllib.parse import uuid import traceback @@ -132,7 +132,7 @@ def _streaming_remote_call(url, payload, class ServiceConnection(object): def __init__(self, server_and_port, backend_endpoint, session_factory): - self.url = urlparse.urljoin('http://%s' % server_and_port, backend_endpoint) + self.url = urllib.parse.urlparse.urljoin('http://%s' % server_and_port, backend_endpoint) self._session_factory = session_factory def __getattr__(self, name): @@ -154,8 +154,8 @@ class ServiceConnection(object): class RemoteVCSMaker(object): def __init__(self, server_and_port, backend_endpoint, backend_type, session_factory): - self.url = urlparse.urljoin('http://%s' % server_and_port, backend_endpoint) - self.stream_url = urlparse.urljoin('http://%s' % server_and_port, backend_endpoint+'/stream') + self.url = urllib.parse.urlparse.urljoin('http://%s' % server_and_port, backend_endpoint) + self.stream_url = urllib.parse.urlparse.urljoin('http://%s' % server_and_port, backend_endpoint+'/stream') self._session_factory = session_factory self.backend_type = backend_type @@ -356,7 +356,7 @@ class VcsHttpProxy(object): retries = Retry(total=5, connect=None, read=None, redirect=None) adapter = requests.adapters.HTTPAdapter(max_retries=retries) - self.base_url = urlparse.urljoin('http://%s' % server_and_port, backend_endpoint) + self.base_url = urllib.parse.urlparse.urljoin('http://%s' % server_and_port, backend_endpoint) self.session = requests.Session() self.session.mount('http://', adapter) diff --git a/rhodecode/model/validation_schema/widgets.py b/rhodecode/model/validation_schema/widgets.py --- a/rhodecode/model/validation_schema/widgets.py +++ b/rhodecode/model/validation_schema/widgets.py @@ -21,7 +21,7 @@ import logging import deform.widget -from deform.widget import null, OptGroup, string_types +from deform.widget import null, OptGroup log = logging.getLogger(__name__) @@ -34,7 +34,7 @@ def _normalize_choices(values): result.append(OptGroup(item.label, *normalized_options)) else: value, description, help_block = item - if not isinstance(value, string_types): + if not isinstance(value, str): value = str(value) result.append((value, description, help_block)) return result diff --git a/rhodecode/tests/lib/middleware/test_simplegit.py b/rhodecode/tests/lib/middleware/test_simplegit.py --- a/rhodecode/tests/lib/middleware/test_simplegit.py +++ b/rhodecode/tests/lib/middleware/test_simplegit.py @@ -19,7 +19,7 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import pytest -import urlparse +import urllib.parse import mock import simplejson as json @@ -30,7 +30,7 @@ import rhodecode.lib.middleware.simplegi def get_environ(url, request_method): """Construct a minimum WSGI environ based on the URL.""" - parsed_url = urlparse.urlparse(url) + parsed_url = urllib.parse.urlparse.urlparse(url) environ = { 'PATH_INFO': parsed_url.path, 'QUERY_STRING': parsed_url.query, diff --git a/rhodecode/tests/lib/middleware/test_simplehg.py b/rhodecode/tests/lib/middleware/test_simplehg.py --- a/rhodecode/tests/lib/middleware/test_simplehg.py +++ b/rhodecode/tests/lib/middleware/test_simplehg.py @@ -18,7 +18,7 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ -import urlparse +import urllib.parse import mock import pytest @@ -31,7 +31,7 @@ import rhodecode.lib.middleware.simplehg def get_environ(url): """Construct a minimum WSGI environ based on the URL.""" - parsed_url = urlparse.urlparse(url) + parsed_url = urllib.parse.urlparse.urlparse(url) environ = { 'PATH_INFO': parsed_url.path, 'QUERY_STRING': parsed_url.query, diff --git a/rhodecode/tests/utils.py b/rhodecode/tests/utils.py --- a/rhodecode/tests/utils.py +++ b/rhodecode/tests/utils.py @@ -27,11 +27,11 @@ import tempfile import urllib.request, urllib.error, urllib.parse from lxml.html import fromstring, tostring from lxml.cssselect import CSSSelector -from urlparse import urlparse, parse_qsl +import urllib.parse.urlparse from urllib.parse import unquote_plus import webob -from webtest.app import TestResponse, TestApp, string_types +from webtest.app import TestResponse, TestApp from webtest.compat import print_stderr import pytest @@ -67,7 +67,7 @@ class CustomTestResponse(TestResponse): if 'no' in kw: no = kw['no'] del kw['no'] - if isinstance(no, string_types): + if isinstance(no, str): no = [no] else: no = [] @@ -316,8 +316,8 @@ class _Url(object): """ def __init__(self, url): - parts = urlparse(url) - _query = frozenset(parse_qsl(parts.query)) + parts = urllib.parse.urlparse(url) + _query = frozenset(urllib.parse.parse_qsl(parts.query)) _path = unquote_plus(parts.path) parts = parts._replace(query=_query, path=_path) self.parts = parts