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

force _content to be bytes, not bytearray #2

Closed
wants to merge 1 commit into from

Conversation

vukasin
Copy link

@vukasin vukasin commented Jun 7, 2015

having _content as bytearray causes chardet to throw a ValueError. Here is an example of requesting a non-existing design doc.

Traceback (most recent call last):
  File "/home/vukasin/.local/lib64/python3.4/site-packages/aiohttp/server.py", line 272, in start
    yield from self.handle_request(message, payload)
  File "/home/vukasin/.local/lib64/python3.4/site-packages/aiohttp/web.py", line 85, in handle_request
    resp = yield from handler(request)
  File "/usr/lib64/python3.4/asyncio/tasks.py", line 105, in coro
    res = yield from res
  File "/home/vukasin/peach-2/peach/queue/__init__.py", line 43, in get
    q = yield from ddoc.view("queue", name)
  File "/home/vukasin/.local/lib64/python3.4/site-packages/aiocouchdb/v1/designdoc.py", line 332, in view
    params=params))
  File "/home/vukasin/.local/lib64/python3.4/site-packages/aiocouchdb/views.py", line 52, in request
    yield from resp.maybe_raise_error()
  File "/home/vukasin/.local/lib64/python3.4/site-packages/aiocouchdb/errors.py", line 140, in maybe_raise_error
    data = yield from resp.json()
  File "/home/vukasin/.local/lib64/python3.4/site-packages/aiohttp/client_reqrep.py", line 703, in json
    encoding = self._get_encoding()
  File "/home/vukasin/.local/lib64/python3.4/site-packages/aiohttp/client_reqrep.py", line 671, in _get_encoding
    encoding = chardet.detect(self._content)['encoding']
  File "/home/vukasin/.local/lib64/python3.4/site-packages/chardet/__init__.py", line 26, in detect
    raise ValueError('Expected a bytes object, not a unicode object')
ValueError: Expected a bytes object, not a unicode object

having _content as bytearray causes chardet to throw a ValueError.
@kxepal
Copy link
Member

kxepal commented Jun 8, 2015

Thanks for the patch!
This issue should be fixed by 682bdaaa commit . Personally, I don't use chardet anywhere, but could you test if the master works for you? If it does will make a new release.

P.S. Also, chardet @ master should be able to handle bytearrays as well chardet/chardet#57

@vukasin vukasin closed this Sep 3, 2015
@vukasin
Copy link
Author

vukasin commented Sep 3, 2015

no longer relevant since it has been fixed upstream

@vukasin vukasin deleted the patch-1 branch September 3, 2015 07:42
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

Successfully merging this pull request may close these issues.

None yet

2 participants