Skip to content

Instantly share code, notes, and snippets.

@adiroiban
Created October 11, 2017 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adiroiban/9334396160f8287cad3e1141a50d3ac7 to your computer and use it in GitHub Desktop.
Save adiroiban/9334396160f8287cad3e1141a50d3ac7 to your computer and use it in GitHub Desktop.
Urllib quote strange behaviour
(Pdb) result
u'/ci-test-site/Shared Documents/v2/no such+\u2603'
(Pdb) urllib.quote(result.encode('utf-8'), safe=b'/+')
*** UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)
(Pdb) urllib.quote(result.encode('utf-8'), safe=b'+/')
'/ci-test-site/Shared%20Documents/v2/no%20such+%E2%98%83'
(Pdb) urllib.quote(result.encode('utf-8'), safe=b'/')
'/ci-test-site/Shared%20Documents/v2/no%20such%2B%E2%98%83'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment