Skip to content

Commit

Permalink
refactor(gtoken): descriptive error message (ssut#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssut authored and c-goosen committed Sep 19, 2024
1 parent 7470d81 commit 414d676
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions googletrans/gtoken.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,7 @@ def _update(self):
code = code.group(1).replace('var ', '')
# unescape special ascii characters such like a \x3d(=)
code = code.encode().decode('unicode-escape')

try:
# this will be the same as python code after stripping out a reserved word 'var'
code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
# unescape special ascii characters such like a \x3d(=)
code = code.encode().decode('unicode-escape')
except AttributeError:
raise Exception('Could not find TKK token for this request.\nSee https://github.com/ssut/py-googletrans/issues/234 for more details.')
except:
raise


if code:
tree = ast.parse(code)
visit_return = False
Expand Down

0 comments on commit 414d676

Please sign in to comment.