klein icon indicating copy to clipboard operation
klein copied to clipboard

Keys and values in request.args are returned as byes in Python3

Open isaacgr opened this issue 5 years ago • 1 comments

With Python3, the keys and values for request.args returned when submitting form data to an app.route are returned as bytes, not strings.

2020-06-29 23:11:10-0400 [-] (Pdb) {b'username': [b'irowell'], b'email': [b'[email protected]'], b'password': [b'test']}
request.args['username']
2020-06-29 23:11:21-0400 [-] (Pdb) *** KeyError: 'username'
request.args[b'username']
2020-06-29 23:20:01-0400 [-] (Pdb) [b'irowell']

So either the user would have to convert the kv pairs to string before parsing, or use bytes when looking up values in the dictionary. Is there anythign that handles this natively?

isaacgr avatar Jun 30 '20 03:06 isaacgr

Not presently… Klein is very bytes-centric at the moment.

What I think I'd like to see is a deprecation of request.args, and the addition of a request.url which is a Hyperlink URL, and so can access the args through that object instead.

wsanchez avatar Jun 30 '20 18:06 wsanchez