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


The following commit(s) were added to refs/heads/trunk by this push:
     new 9a4a677823 Removed Python < 2.7 support from formatting.py
9a4a677823 is described below

commit 9a4a67782311e4a6ffe3aad0516c33016f187c54
Author: Bernardo Botella Corbi <conta...@bernardobotella.com>
AuthorDate: Mon Aug 1 10:57:04 2022 -0700

    Removed Python < 2.7 support from formatting.py
    
    Patch by Bernardo Botella Corbi, reviewed by Brad Schoening, ycai and
    brandonwilliams for CASSANDRA-17694
---
 CHANGES.txt                  |  1 +
 pylib/cqlshlib/formatting.py | 16 +++-------------
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index d1957a4667..e25c228828 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.2
+ * Removed Python < 2.7 support from formatting.py (CASSANDRA-17694)
  * Cleanup pylint issues with pylexotron.py (CASSANDRA-17779)
  * NPE bug in streaming checking if SSTable is being repaired (CASSANDRA-17801)
  * Users of NativeLibrary should handle lack of JNA appropriately when running 
in client mode (CASSANDRA-17794)
diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py
index b49a29aebd..39bc060485 100644
--- a/pylib/cqlshlib/formatting.py
+++ b/pylib/cqlshlib/formatting.py
@@ -326,19 +326,9 @@ def format_integer_type(val, colormap, thousands_sep=None, 
**_):
     return colorme(bval, colormap, 'int')
 
 
-# We can get rid of this in cassandra-2.2
-if sys.version_info >= (2, 7):
-    def format_integer_with_thousands_sep(val, thousands_sep=','):
-        return "{:,.0f}".format(val).replace(',', thousands_sep)
-else:
-    def format_integer_with_thousands_sep(val, thousands_sep=','):
-        if val < 0:
-            return '-' + format_integer_with_thousands_sep(-val, thousands_sep)
-        result = ''
-        while val >= 1000:
-            val, r = divmod(val, 1000)
-            result = "%s%03d%s" % (thousands_sep, r, result)
-        return "%d%s" % (val, result)
+def format_integer_with_thousands_sep(val, thousands_sep=','):
+    return "{:,.0f}".format(val).replace(',', thousands_sep)
+
 
 formatter_for('long')(format_integer_type)
 formatter_for('int')(format_integer_type)


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

Reply via email to