Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug on google_trans_new.py - google_translator.translate #55

Open
Manu-Fraile opened this issue Jun 6, 2022 · 1 comment
Open

Bug on google_trans_new.py - google_translator.translate #55

Manu-Fraile opened this issue Jun 6, 2022 · 1 comment

Comments

@Manu-Fraile
Copy link

Manu-Fraile commented Jun 6, 2022

Hi!

I've been experiencing the following error:
File "/usr/lib/python3.8/json/__init__.py", line 357, in loads return _default_decoder.decode(s) File "/usr/lib/python3.8/json/decoder.py", line 340, in decode raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 499 (char 498)

raised by:
response = (decoded_line + ']')
response = json.loads(response)

within the translate function of google_translator class.

I found a solution that works for me that is skipping the first line where the error occurs and adds a ']' and directly go with the decoded_line so that:
`[...]

if "MkEWBc" in decoded_line:
try:
response = json.loads(decoded_line)
response = list(response)
response = json.loads(response[0][2])
response_ = list(response)
response = response_[1][0]

[...]`

Is this solution for the bug valid?

Many thanks!

@WillDawnlll
Copy link

not noticed this issue before i use this library... i used same way to fix exception finally
is google response api changed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants