terryyin / terryyin/translate-python

raise JSONDecodeError("Expecting value", s, err.value) from None

Open
#54 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
759
Forks
152
PR merge metrics
No merged PRs in 30d

Description

Attempted to mimic the example and ran into the following error:

from translate import Translator
translator= Translator(to_lang="zh")
translation = translator.translate("This is a pen.")

[Traceback (most recent call last):

File "", line 3, in
translation = translator.translate("This is a pen.")

File "C:\ProgramData\Anaconda3\lib\site-packages\translate\translate.py", line 42, in translate
return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)

File "C:\ProgramData\Anaconda3\lib\site-packages\translate\translate.py", line 42, in
return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)

File "C:\ProgramData\Anaconda3\lib\site-packages\translate\providers\mymemory_translated.py", line 42, in get_translation
data = self._make_request(text)

File "C:\ProgramData\Anaconda3\lib\site-packages\translate\providers\mymemory_translated.py", line 39, in _make_request
return response.json()

File "C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py", line 896, in json
return complexjson.loads(self.text, **kwargs)

File "C:\ProgramData\Anaconda3\lib\json_init_.py", line 348, in loads
return _default_decoder.decode(s)

File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())

File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None

JSONDecodeError: Expecting value](url)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example using Translator in translate.py, then trace the request through providers/mymemory_translated.py where response.json() raises JSONDecodeError. Inspect the returned response and determine the expected behavior for this failure; done means the example no longer fails with an unhandled JSON decoding error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.