From 59e6c34b9e99d1e291585a1cbbb20e895db9182e Mon Sep 17 00:00:00 2001 From: ThugPigeon653 <89567974+ThugPigeon653@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:07:39 +1000 Subject: [PATCH 1/3] fixed encoding --- googlemaps/client.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/googlemaps/client.py b/googlemaps/client.py index d1f4ab6a..424f4f7d 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -516,19 +516,18 @@ def urlencode_params(params): try: - unicode # NOTE(cbro): `unicode` was removed in Python 3. In Python 3, NameError is # raised here, and caught below. def normalize_for_urlencode(value): - """(Python 2) Converts the value to a `str` (raw bytes).""" - if isinstance(value, unicode): - return value.encode('utf8') - - if isinstance(value, str): - return value - - return normalize_for_urlencode(str(value)) + if(sys.version[0]<=2): + """(Python 2) Converts the value to a `str` (raw bytes).""" + if isinstance(value, str): + return value + else: + return value.encode('utf8') + else: + return value.encode('utf-8') except NameError: def normalize_for_urlencode(value): From 78ade661660dbce1df53292ae7139542f6b77d47 Mon Sep 17 00:00:00 2001 From: ThugPigeon653 <89567974+ThugPigeon653@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:14:43 +1000 Subject: [PATCH 2/3] fixed TypeError caused by py version check --- googlemaps/client.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/client.py b/googlemaps/client.py index 424f4f7d..fab5cc51 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -520,7 +520,7 @@ def urlencode_params(params): # raised here, and caught below. def normalize_for_urlencode(value): - if(sys.version[0]<=2): + if(int(sys.version[0])<=2): """(Python 2) Converts the value to a `str` (raw bytes).""" if isinstance(value, str): return value diff --git a/setup.cfg b/setup.cfg index 56320971..d281685d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [tool:pytest] -addopts = -rsxX --cov=googlemaps --cov-report= +addopts = -rsxX [coverage:run] omit = From d55834c7821316372a4b7f5c463505926e61f3db Mon Sep 17 00:00:00 2001 From: ThugPigeon653 <89567974+ThugPigeon653@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:26:39 +1000 Subject: [PATCH 3/3] fix(api) --- googlemaps/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemaps/client.py b/googlemaps/client.py index fab5cc51..23bd509b 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -517,7 +517,7 @@ def urlencode_params(params): try: # NOTE(cbro): `unicode` was removed in Python 3. In Python 3, NameError is - # raised here, and caught below. + # raised here, and caught below. def normalize_for_urlencode(value): if(int(sys.version[0])<=2):