python3 utf8 characters in url get mangled
Using python3
The following client built using requests
import requests
import urllib
if __name__ == '__main__':
s = requests.Session()
url = 'http://localhost:4040/' + urllib.parse.quote("Ω")
print(url)
r = s.get(url)
print(r)
print('What we expect:')
print('Ω == Ω')
print('What we got:')
print(r.content.decode('utf8'))
When run against the following server:
import web
class allofit:
def GET(self, arg1):
if (arg1 != 'Ω'):
return 'Ω != '+arg1
return 'Ω == '+arg1+' YAY!'
urls = ('/([^/]+)', 'allofit',)
app = web.application(urls, globals(), autoreload=True)
if __name__ == '__main__':
app.run()
Produces:
http://localhost:4040/%E2%84%A6
<Response [200]>
What we expect:
Ω == Ω
What we got:
Ω != â
¦
Notice that the % escaped utf8 character is not preserved. Bug?