Fix up posting some changes including unicode with Python 2.x
Review Request #9748 — Created March 5, 2018 and submitted
The changes I had made to make things encode correctly with Python 3
regressed posting diffs with unicode characters under Python 2. After
some investigation, what's needed is to use the native string type
(str
) for headers and URLs passed into urllib2, rather than either
unicode or bytes.
- Posted a change including an emoji under both Python 2.7 and 3.6.
- Ran unit tests under Python 2.7 and 3.6.
Description | From | Last Updated |
---|---|---|
Can we do the same with method, and maybe even normalize headers? I can see this coming up a lot … |
chipx86 | |
testtesttest |
TE testaaaaaa | |
Since we're Python 2.7 now, this can be: self.headers = { str(key): str(value) for key, value in six.iteritems(headers) } |
chipx86 | |
Same as above. |
chipx86 | |
Is this still needed now that HttpRequest normalizes? |
chipx86 |
-
-
rbtools/api/request.py (Diff revision 1) Can we do the same with
method
, and maybe even normalize headers? I can see this coming up a lot with contributed/third-party code, and it'd be nice to just cast things in one place and have it be done.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+28 -19) |
Checks run (2 succeeded)
-
-
rbtools/api/request.py (Diff revision 2) Since we're Python 2.7 now, this can be:
self.headers = { str(key): str(value) for key, value in six.iteritems(headers) }
-
-
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+34 -17) |