diff options
author | Darik Gamble <darik.gamble.spam@gmail.com> | 2016-10-03 10:24:08 -0400 |
---|---|---|
committer | Darik Gamble <darik.gamble.spam@gmail.com> | 2016-10-03 10:24:08 -0400 |
commit | a61090c1f3ab4ed14c132a11ee5f5f5aecafcc02 (patch) | |
tree | 266f3d653fb1792a8faaca3ae1a7031b050e4e00 | |
parent | feea19442b98f8cafab6aa3755a991778a0e2f3d (diff) |
Don't coerce strings into numeric type formatting
-rw-r--r-- | pgcli/packages/tabulate.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pgcli/packages/tabulate.py b/pgcli/packages/tabulate.py index e92d2ec0..8750e6b5 100644 --- a/pgcli/packages/tabulate.py +++ b/pgcli/packages/tabulate.py @@ -8,6 +8,7 @@ from collections import namedtuple from platform import python_version_tuple from wcwidth import wcswidth from ..encodingutils import utf8tounicode +from decimal import Decimal import re @@ -301,15 +302,14 @@ def _isnumber(string): def _isint(string): """ - >>> _isint("123") + >>> _isint(123) True + >>> _isint("123") + False >>> _isint("123.45") False """ - return type(string) is _int_type or type(string) is _long_type or \ - (isinstance(string, _binary_type) or isinstance(string, _text_type)) and \ - _isconvertible(int, string) - + return type(string) is _int_type or type(string) is _long_type def _type(string, has_invisible=True): """The least generic type (type(None), int, float, str, unicode). @@ -319,7 +319,7 @@ def _type(string, has_invisible=True): >>> _type("foo") is type("") True >>> _type("1") is type(1) - True + False >>> _type('\x1b[31m42\x1b[0m') is type(42) True >>> _type('\x1b[31m42\x1b[0m') is type(42) @@ -339,7 +339,7 @@ def _type(string, has_invisible=True): return _text_type elif _isint(string): return int - elif _isnumber(string): + elif isinstance(string, (float, Decimal)): return float elif isinstance(string, _binary_type): return _binary_type |