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

ValueError: Only unicode objects are escapable on client.info() #177

Open
mechanical-girl opened this issue Jul 30, 2024 · 1 comment
Open

Comments

@mechanical-girl
Copy link

mechanical-girl commented Jul 30, 2024

When calling client.info(), the following error occurs:

Traceback (most recent call last):
  File "/Users/mechanical-girl/blogup/main.py", line 92, in <module>
    register()
  File "/Users/mechanical-girl/blogup/main.py", line 89, in register
    client.info()
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/pytumblr/__init__.py", line 39, in info
    return self.send_api_request("get", "/v2/user/info")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/pytumblr/__init__.py", line 578, in send_api_request
    return self.request.get(url, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/pytumblr/request.py", line 49, in get
    resp = requests.get(url, allow_redirects=False, headers=self.headers, auth=self.oauth)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/requests/sessions.py", line 484, in prepare_request
    p.prepare(
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/requests/models.py", line 371, in prepare
    self.prepare_auth(auth, url)
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/requests/models.py", line 602, in prepare_auth
    r = auth(self)
        ^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/requests_oauthlib/oauth1_auth.py", line 103, in __call__
    r.url, headers, _ = self.client.sign(
                        ^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 351, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 165, in get_oauth_signature
    uri, headers, body = self._render(request)
                         ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 247, in _render
    headers = parameters.prepare_headers(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 25, in wrapper
    return target(params, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/oauthlib/oauth1/rfc5849/parameters.py", line 53, in prepare_headers
    escaped_value = utils.escape(value)
                    ^^^^^^^^^^^^^^^^^^^
  File "/Users/mechanical-girl/blogup/lib/python3.12/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 49, in escape
    raise ValueError('Only unicode objects are escapable. ' +
ValueError: Only unicode objects are escapable. Got <generator object to_unicode.<locals>.<genexpr> at 0x103f43760> of type <class 'generator'>.
@mechanical-girl
Copy link
Author

mechanical-girl commented Jul 30, 2024

This appears to be fixed by adding from __future__ import unicode_literals to the top of the file. Could documentation be updated to reflect that?

Never mind, this is considered bad practice.

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

1 participant