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

unicode issues #51

Closed
dkvdm opened this issue Sep 30, 2021 · 1 comment
Closed

unicode issues #51

dkvdm opened this issue Sep 30, 2021 · 1 comment

Comments

@dkvdm
Copy link

dkvdm commented Sep 30, 2021

When I follow the example to retrieve data I'm greeted with the following stacktrace:

In [4]: supabase.table("countries").select("*").execute()
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-4-91499f52c962> in <module>
----> 1 supabase.table("countries").select("*").execute()

/usr/lib/python3.8/site-packages/supabase_py/client.py in table(self, table_name)
     72         Alternatively you can use the `._from()` method.
     73         """
---> 74         return self.from_(table_name)
     75 
     76     def from_(self, table_name: str) -> SupabaseQueryBuilder:

/usr/lib/python3.8/site-packages/supabase_py/client.py in from_(self, table_name)
     79         See the `table` method.
     80         """
---> 81         query_builder = SupabaseQueryBuilder(
     82             url=f"{self.rest_url}/{table_name}",
     83             headers=self._get_auth_headers(),

/usr/lib/python3.8/site-packages/supabase_py/lib/query_builder.py in __init__(self, url, headers, schema, realtime, table)
     71             **headers,
     72         }
---> 73         self.session = AsyncClient(base_url=url, headers=headers)
     74         # self._subscription = SupabaseRealtimeClient(realtime, schema, table)
     75         # self._realtime = realtime

/usr/lib/python3.8/site-packages/httpx/_client.py in __init__(self, auth, params, headers, cookies, verify, cert, http2, proxies, timeout, limits, pool_limits, max_redirects, event_hooks, base_url, transport, app, trust_env)
   1209         trust_env: bool = True,
   1210     ):
-> 1211         super().__init__(
   1212             auth=auth,
   1213             params=params,

/usr/lib/python3.8/site-packages/httpx/_client.py in __init__(self, auth, params, headers, cookies, timeout, max_redirects, event_hooks, base_url, trust_env)
     98         self._auth = self._build_auth(auth)
     99         self._params = QueryParams(params)
--> 100         self.headers = Headers(headers)
    101         self._cookies = Cookies(cookies)
    102         self._timeout = Timeout(timeout)

/usr/lib/python3.8/site-packages/httpx/_models.py in __init__(self, headers, encoding)
    549             self._list = list(headers._list)
    550         elif isinstance(headers, dict):
--> 551             self._list = [
    552                 (
    553                     normalize_header_key(k, lower=False, encoding=encoding),

/usr/lib/python3.8/site-packages/httpx/_models.py in <listcomp>(.0)
    553                     normalize_header_key(k, lower=False, encoding=encoding),
    554                     normalize_header_key(k, lower=True, encoding=encoding),
--> 555                     normalize_header_value(v, encoding),
    556                 )
    557                 for k, v in headers.items()

/usr/lib/python3.8/site-packages/httpx/_utils.py in normalize_header_value(value, encoding)
     54     if isinstance(value, bytes):
     55         return value
---> 56     return value.encode(encoding or "ascii")
     57 
     58 

UnicodeEncodeError: 'ascii' codec can't encode character '\u2026' in position 50: ordinal not in range(128)

In [5]: data = supabase.table("countries").select("*").execute()
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-5-a2ce57b52ae2> in <module>
----> 1 data = supabase.table("countries").select("*").execute()

/usr/lib/python3.8/site-packages/supabase_py/client.py in table(self, table_name)
     72         Alternatively you can use the `._from()` method.
     73         """
---> 74         return self.from_(table_name)
     75 
     76     def from_(self, table_name: str) -> SupabaseQueryBuilder:

/usr/lib/python3.8/site-packages/supabase_py/client.py in from_(self, table_name)
     79         See the `table` method.
     80         """
---> 81         query_builder = SupabaseQueryBuilder(
     82             url=f"{self.rest_url}/{table_name}",
     83             headers=self._get_auth_headers(),

/usr/lib/python3.8/site-packages/supabase_py/lib/query_builder.py in __init__(self, url, headers, schema, realtime, table)
     71             **headers,
     72         }
---> 73         self.session = AsyncClient(base_url=url, headers=headers)
     74         # self._subscription = SupabaseRealtimeClient(realtime, schema, table)
     75         # self._realtime = realtime

/usr/lib/python3.8/site-packages/httpx/_client.py in __init__(self, auth, params, headers, cookies, verify, cert, http2, proxies, timeout, limits, pool_limits, max_redirects, event_hooks, base_url, transport, app, trust_env)
   1209         trust_env: bool = True,
   1210     ):
-> 1211         super().__init__(
   1212             auth=auth,
   1213             params=params,

/usr/lib/python3.8/site-packages/httpx/_client.py in __init__(self, auth, params, headers, cookies, timeout, max_redirects, event_hooks, base_url, trust_env)
     98         self._auth = self._build_auth(auth)
     99         self._params = QueryParams(params)
--> 100         self.headers = Headers(headers)
    101         self._cookies = Cookies(cookies)
    102         self._timeout = Timeout(timeout)

/usr/lib/python3.8/site-packages/httpx/_models.py in __init__(self, headers, encoding)
    549             self._list = list(headers._list)
    550         elif isinstance(headers, dict):
--> 551             self._list = [
    552                 (
    553                     normalize_header_key(k, lower=False, encoding=encoding),

/usr/lib/python3.8/site-packages/httpx/_models.py in <listcomp>(.0)
    553                     normalize_header_key(k, lower=False, encoding=encoding),
    554                     normalize_header_key(k, lower=True, encoding=encoding),
--> 555                     normalize_header_value(v, encoding),
    556                 )
    557                 for k, v in headers.items()

/usr/lib/python3.8/site-packages/httpx/_utils.py in normalize_header_value(value, encoding)
     54     if isinstance(value, bytes):
     55         return value
---> 56     return value.encode(encoding or "ascii")
     57 
     58 

UnicodeEncodeError: 'ascii' codec can't encode character '\u2026' in position 50: ordinal not in range(128)

I've tried this on Python 3.7, 3.8, and 3.9 all with similar results. I've also tried different OSes (OSX, Linux), but both fail in similar fashion.

@dkvdm
Copy link
Author

dkvdm commented Sep 30, 2021

Disregard, something went completely wrong with copying in the api key, which caused unicode issues.

Closing!

@dkvdm dkvdm closed this as completed Sep 30, 2021
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