diff --git a/git_review/cmd.py b/git_review/cmd.py index 9607fd90..19adfae2 100644 --- a/git_review/cmd.py +++ b/git_review/cmd.py @@ -17,24 +17,22 @@ from __future__ import print_function import argparse +import configparser import datetime import getpass import json import os import re import shlex -import six import subprocess import sys import textwrap +from urllib.parse import urlencode +from urllib.parse import urljoin +from urllib.parse import urlparse import pkg_resources import requests -from six.moves import configparser -from six.moves import input as do_input -from six.moves.urllib.parse import urlencode -from six.moves.urllib.parse import urljoin -from six.moves.urllib.parse import urlparse VERBOSE = False @@ -138,11 +136,7 @@ def run_command_status(*argv, **kwargs): if VERBOSE: print(datetime.datetime.now(), "Running:", " ".join(argv)) if len(argv) == 1: - # for python2 compatibility with shlex - if sys.version_info < (3,) and isinstance(argv[0], six.text_type): - argv = shlex.split(argv[0].encode('utf-8')) - else: - argv = shlex.split(str(argv[0])) + argv = shlex.split(str(argv[0])) stdin = kwargs.pop('stdin', None) newenv = os.environ.copy() newenv['LANG'] = 'C' @@ -416,7 +410,7 @@ def add_remote(scheme, hostname, port, project, remote, usepushurl): print("No remote set, testing %s" % remote_url) if not test_remote_url(remote_url): print("Could not connect to gerrit.") - username = do_input("Enter your gerrit username: ") + username = input("Enter your gerrit username: ") remote_url = make_remote_url(scheme, username, hostname, port, project) print("Trying again with %s" % remote_url) if not test_remote_url(remote_url): @@ -954,7 +948,7 @@ def assert_one_change(remote, branch, yes, have_hook): "branches (for independent changes).") print("\nThe outstanding commits are:\n\n%s\n\n" "Do you really want to submit the above commits?" % output) - yes_no = do_input("Type 'yes' to confirm, other to cancel: ") + yes_no = input("Type 'yes' to confirm, other to cancel: ") if yes_no.lower().strip() != "yes": print("Aborting.") sys.exit(1) @@ -1729,15 +1723,6 @@ review. def main(): - # workaround for avoiding UnicodeEncodeError on print() with older python - if sys.version_info[0] < 3: - # without reload print would fail even if sys.stdin.encoding - # would report utf-8 - # see: https://stackoverflow.com/a/23847316/99834 - stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr - reload(sys) # noqa - sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr - sys.setdefaultencoding(os.environ.get('PYTHONIOENCODING', 'utf-8')) try: _main() diff --git a/git_review/tests/test_unit.py b/git_review/tests/test_unit.py index 553cfac2..0854ebc7 100644 --- a/git_review/tests/test_unit.py +++ b/git_review/tests/test_unit.py @@ -17,6 +17,7 @@ import argparse import functools +import io import os import sys import textwrap @@ -29,13 +30,6 @@ from git_review import cmd from git_review.tests import IsoEnvDir from git_review.tests import utils -# Use of io.StringIO in python =< 2.7 requires all strings handled to be -# unicode. See if StringIO.StringIO is available first -try: - import StringIO as io -except ImportError: - import io - class ConfigTestCase(testtools.TestCase): """Class testing config behavior.""" diff --git a/requirements.txt b/requirements.txt index 289b82a4..944892c0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ requests>=1.1 -six diff --git a/setup.cfg b/setup.cfg index 85fe3642..dfeba852 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,8 +4,9 @@ summary = Tool to submit code to Gerrit description-file = README.rst license = Apache License (2.0) classifiers = - Programming Language :: Python :: 2 Programming Language :: Python :: 3 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 Programming Language :: Python Development Status :: 5 - Production/Stable Environment :: Console @@ -19,6 +20,7 @@ author = OpenStack author-email = openstack-infra@lists.openstack.org home-page = http://docs.openstack.org/infra/git-review/ project-url = http://docs.openstack.org/infra/ +python-requires = >= 3.5 [files] packages = diff --git a/setup.py b/setup.py index 10d670de..66481e7d 100755 --- a/setup.py +++ b/setup.py @@ -17,4 +17,4 @@ import setuptools -setuptools.setup(setup_requires=['pbr'], pbr=True) +setuptools.setup(setup_requires=['pbr>=4.1.0'], pbr=True) diff --git a/tox.ini b/tox.ini index 45e4541b..c5bae522 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = linters,docs,py27,py3{4,5,6,7} +envlist = linters,docs,py3{5,6,7} ignore_basepython_conflict = true [testenv]