Simpler request helper functions that accept bytes and unicode args
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 838
- Forks
- 123
- Avg merge
- 7h 58m
- Merged PRs (30d)
- 12
Description
This is related to a bug I wrote a while back #108 for Klein and 8905 for Twisted. It would make writing code more pleasant if certain functions of the Request object would accept both bytes and unicode. This would also bridge gaps between writing Py2 and Py3 code. This issue was primarily created because there are inconsistencies with:
- Headers (param can be
bytesorunicode) - adding cookies (param can be
bytesorunicode) - getting cookies (param can only be
bytes) - getting
request.args(param can only bebytes)
It is easy to do something like 'unicode or py2 str key'.encode('utf-8') before passing it to the various getter/setter functions, however the more popular Python web frameworks never force users to do this and Klein should follow suite. I'm well aware that these are upstream Twisted issues, but it's extremely noticeable in Klein. My hope is to deploy a solution here, test it out with the people who use Klein, then merge them upstream.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Klein's Request object and compare the handling of Headers, addCookie, cookie lookup, and request.args, then review related issues #108 and Twisted ticket 8905. The work is complete when the affected helpers consistently accept both bytes and unicode and the behavior has been tested with Klein users before considering an upstream change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100