Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Issue with quickstart tutorial python3.4 str no attribute decode #49

@Fi3

Description

@Fi3

With the code that I can find in the quickstart tutorial I have this error:

_Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
self.run()
File "/usr/lib/python3.4/multiprocessing/process.py", line 93, in run
self._target(_self._args, *_self._kwargs)
File "/usr/local/lib/python3.4/dist-packages/datasift/client.py", line 237, in stream
options = ssl.optionsForClientTLS(hostname=WEBSOCKET_HOST.decode("utf-8"))
AttributeError: 'str' object has no attribute 'decode'

If I change in the tutorial's code
client = datasift.Client('DATASIFT_USERNAME', 'DATASIFT_API_KEY')
with
client = datasift.Client(b'DATASIFT_USERNAME', b'DATASIFT_API_KEY')
I have this error:

Traceback (most recent call last):
File "tutorial_datasift.py", line 9, in
fltr = client.compile(csdl)
File "/usr/local/lib/python3.4/dist-packages/datasift/client.py", line 256, in compile
return self.request.post('compile', data=dict(csdl=csdl))
File "/usr/local/lib/python3.4/dist-packages/datasift/request.py", line 46, in post
return self.build_response(self('post', path, params=params, headers=headers, data=data), path=path)
File "/usr/local/lib/python3.4/dist-packages/datasift/request.py", line 86, in build_response
raise AuthException(data)
datasift.exceptions.AuthException: {'error': 'Authorization failed'}

If I change in client.py line 237
options = ssl.optionsForClientTLS(hostname=WEBSOCKET_HOST.decode("utf-8"))
with
options = ssl.optionsForClientTLS(hostname=WEBSOCKET_HOST)
it seems run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions