Skip to content

Commit

Permalink
util.py: Encode data using utf-8, not ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
user234683 committed Mar 3, 2021
1 parent fe05aed commit a3535d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions youtube/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ def fetch_url_response(url, headers=(), timeout=15, data=None,
if data is not None:
method = "POST"
if isinstance(data, str):
data = data.encode('ascii')
data = data.encode('utf-8')
elif not isinstance(data, bytes):
data = urllib.parse.urlencode(data).encode('ascii')
data = urllib.parse.urlencode(data).encode('utf-8')

if cookiejar_send is not None or cookiejar_receive is not None: # Use urllib
req = urllib.request.Request(url, data=data, headers=headers)
Expand Down

0 comments on commit a3535d6

Please sign in to comment.