Skip to content

Commit 651a28a

Browse files
committed
Fixed .encode error (returns byte array in Python 3+) using try/catch.
1 parent 5f1fade commit 651a28a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

alchemyapi.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,12 @@ def __analyze(self, endpoint, params, post_data=bytearray()):
737737
params['outputMode'] = 'json'
738738
# Insert the base url
739739

740-
post_url = AlchemyAPI.BASE_URL + endpoint + \
741-
'?' + urlencode(params).encode('utf-8')
740+
post_url = ""
741+
try:
742+
post_url = AlchemyAPI.BASE_URL + endpoint + \
743+
'?' + urlencode(params).encode('utf-8')
744+
except TypeError:
745+
post_url = AlchemyAPI.BASE_URL + endpoint + '?' + urlencode(params)
742746

743747
results = ""
744748
try:

0 commit comments

Comments
 (0)