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

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

Open
isaacgr opened this issue Jun 30, 2020 · 1 comment
Open

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

isaacgr opened this issue Jun 30, 2020 · 1 comment

Comments

@isaacgr
Copy link

isaacgr commented Jun 30, 2020

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'test@gmail.com'], 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?

@wsanchez
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants