You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2022/01/26 17:00:33 UTC

[cassandra] 01/02: remove python 2 code which is now EOL and unsupported

This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 1eb777946434a578f2aa673063ba992692c358d4
Author: Brad Schoening <57...@users.noreply.github.com>
AuthorDate: Thu Jan 20 06:19:45 2022 -0500

    remove python 2 code which is now EOL and unsupported
    
    Patch by Brad Schoening; reviewed by brandonwilliams and bereng for
    CASSANDRA-17242
---
 CHANGES.txt                              |  1 +
 README.asc                               |  2 +-
 bin/cqlsh                                |  8 +++++---
 bin/cqlsh.py                             |  9 +--------
 pylib/Dockerfile.ubuntu.py2              |  2 --
 pylib/README.asc                         |  6 ++----
 pylib/cqlshlib/test/test_cqlsh_output.py | 17 -----------------
 7 files changed, 10 insertions(+), 35 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 71a91a3..03a97fa 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.1
+ * Remove python 2.x support from cqlsh (CASSANDRA-17242)
  * Prewarm role and credential caches to avoid timeouts at startup (CASSANDRA-16958)
  * Make capacity/validity/updateinterval/activeupdate for Auth Caches configurable via nodetool (CASSANDRA-17063)
  * Added startup check for read_ahead_kb setting (CASSANDRA-16436)
diff --git a/README.asc b/README.asc
index f1270a8..27850cd 100644
--- a/README.asc
+++ b/README.asc
@@ -12,7 +12,7 @@ For more information, see http://cassandra.apache.org/[the Apache Cassandra web
 Requirements
 ------------
 . Java >= 1.8 (OpenJDK and Oracle JVMS have been tested)
-. Python 3.6+ (for cqlsh; 2.7 works but is deprecated)
+. Python 3.6+ (for cqlsh)
 
 Getting started
 ---------------
diff --git a/bin/cqlsh b/bin/cqlsh
index a962e11..90c9b00 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -62,8 +62,8 @@ is_supported_version() {
     version=$1
     major_version="${version%.*}"
     minor_version="${version#*.}"
-    # python3.6+ is supported. python2.7 is deprecated but still compatible.
-    if [ "$major_version" = 3 ] && [ "$minor_version" -ge 6 ] || [ "$version" = "2.7" ]; then
+    # python3.6+ is supported
+    if [ "$major_version" = 3 ] && [ "$minor_version" -ge 6 ]; then
         echo "supported"
     else
         echo "unsupported"
@@ -79,6 +79,8 @@ run_if_supported_version() {
         if [ "$(is_supported_version "$version")" = "supported" ]; then
             exec "$interpreter" "$($interpreter -c "import os; print(os.path.dirname(os.path.realpath('$0')))")/cqlsh.py" "$@"
             exit
+        else
+            echo "Warning: unsupported version of Python:" $version >&2
         fi
     fi
 }
@@ -88,7 +90,7 @@ if [ "$USER_SPECIFIED_PYTHON" != "" ]; then
     # run a user specified Python interpreter
     run_if_supported_version "$USER_SPECIFIED_PYTHON" "$@"
 else
-    for interpreter in python3 python python2.7; do
+    for interpreter in python3 python; do
         run_if_supported_version "$interpreter" "$@"
     done
 fi
diff --git a/bin/cqlsh.py b/bin/cqlsh.py
index 3c711a9..1a5f84a 100755
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@ -37,7 +37,7 @@ from glob import glob
 from uuid import UUID
 
 if sys.version_info < (3, 6) and sys.version_info[0:2] != (2, 7):
-    sys.exit("\ncqlsh requires Python 3.6+ or Python 2.7 (deprecated)\n")
+    sys.exit("\ncqlsh requires Python 3.6+\n")
 
 # see CASSANDRA-10428
 if platform.python_implementation().startswith('Jython'):
@@ -522,7 +522,6 @@ class Shell(cmd.Cmd):
 
         if tty:
             self.reset_prompt()
-            self.maybe_warn_py2()
             self.report_connection()
             print('Use HELP for help.')
         else:
@@ -609,12 +608,6 @@ class Shell(cmd.Cmd):
         vers['cql'] = self.cql_version
         print("[cqlsh %(shver)s | Cassandra %(build)s | CQL spec %(cql)s | Native protocol v%(protocol)s]" % vers)
 
-    def maybe_warn_py2(self):
-        py2_suppress_warn = 'CQLSH_NO_WARN_PY2'
-        if sys.version_info[0:2] == (2, 7) and not os.environ.get(py2_suppress_warn):
-            print("Python 2.7 support is deprecated. "
-                  "Install Python 3.6+ or set %s to suppress this message.\n" % (py2_suppress_warn,))
-
     def show_session(self, sessionid, partial_session=False):
         print_trace_session(self, self.session, sessionid, partial_session)
 
diff --git a/pylib/Dockerfile.ubuntu.py2 b/pylib/Dockerfile.ubuntu.py2
deleted file mode 100644
index 93016f0..0000000
--- a/pylib/Dockerfile.ubuntu.py2
+++ /dev/null
@@ -1,2 +0,0 @@
-FROM ubuntu:bionic
-RUN apt-get update && apt-get install -y python-minimal
diff --git a/pylib/README.asc b/pylib/README.asc
index b0b6c7d..a192393 100644
--- a/pylib/README.asc
+++ b/pylib/README.asc
@@ -1,11 +1,9 @@
 == Overview
 
 This directory contains code primarily for cqlsh. cqlsh uses cqlshlib in this directory.
-Currently, cqlshlib supports Python 2 as well as Python 3. Support for Python 3 is relatively
-new.
 
 == Requirements
-. Python 3 and 2.7 (for cqlsh)
+. Python 3.6+ (for cqlsh)
 . virtualenv
 . Docker (optional)
 
@@ -32,4 +30,4 @@ This will try to spawn a cqlsh instance inside the Docker container running Ubun
 with minimal Python installation. It will try to connect to the Cassandra instance running on the
 Docker host at port 9042. If you have Cassandra running elsewhere, replace host.docker.internal
 with the IP / hostname as usual. Please ensure that the IP / host is accessible from _within_ the
-Docker container.
\ No newline at end of file
+Docker container.
diff --git a/pylib/cqlshlib/test/test_cqlsh_output.py b/pylib/cqlshlib/test/test_cqlsh_output.py
index 5678def..106f2ee 100644
--- a/pylib/cqlshlib/test/test_cqlsh_output.py
+++ b/pylib/cqlshlib/test/test_cqlsh_output.py
@@ -781,23 +781,6 @@ class TestCqlshOutput(BaseTestCase):
             self.assertRegex(output, '^Connected to .* at %s:%d$'
                                              % (re.escape(TEST_HOST), TEST_PORT))
 
-    @unittest.skipIf(six.PY3, 'Will not emit warning when running Python 3')
-    def test_warn_py2(self):
-        # has the warning
-        with testrun_cqlsh(tty=True, env=self.default_env) as c:
-            self.assertIn('Python 2.7 support is deprecated.', c.output_header, 'cqlsh did not output expected warning.')
-
-        # can suppress
-        env = self.default_env.copy()
-        env['CQLSH_NO_WARN_PY2'] = '1'
-        with testrun_cqlsh(tty=True, env=env) as c:
-            self.assertNotIn('Python 2.7 support is deprecated.', c.output_header, 'cqlsh did not output expected warning.')
-
-    @unittest.skipIf(six.PY2, 'Warning will be emitted when running Python 2.7')
-    def test_no_warn_py3(self):
-        with testrun_cqlsh(tty=True, env=self.default_env) as c:
-            self.assertNotIn('Python 2.7 support is deprecated.', c.output_header, 'cqlsh did not output expected warning.')
-
     @unittest.skipIf(sys.platform == "win32", 'EOF signaling not supported on Windows')
     def test_eof_prints_newline(self):
         with testrun_cqlsh(tty=True, env=self.default_env) as c:

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org