This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年11月06日 18:52 by hfuru, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| parse.diff | hfuru, 2010年11月06日 18:52 | suggested urlencode simplification | ||
| Messages (2) | |||
|---|---|---|---|
| msg120647 - (view) | Author: Hallvard B Furuseth (hfuru) | Date: 2010年11月06日 18:52 | |
urlunparse(url or params = bytes object) produces a result with the repr of the bytes object. urllib.parse.urlunparse(['http', 'host', '/dir', b'params', '', '']) --> "http://host/dir;b'params'" That's confusing since urllib/parse.py goes to a lot of trouble to support both bytes and str. Simplest fix is to only accept str: Index: Lib/urllib/parse.py @@ -219,5 +219,5 @@ def urlunparse(components): scheme, netloc, url, params, query, fragment = components if params: - url = "%s;%s" % (url, params) + url = ';'.join((url, params)) return urlunsplit((scheme, netloc, url, query, fragment)) Some people at comp.lang.python tell me code shouldn't anyway do str() just in case it is needed like urllib does, not that I can make much sense of that discussion. (Subject: harmful str(bytes)). BTW, the str vs bytes code doesn't have to be quite as painful as in urllib.parse, I enclose patch which just rearranges and factors out some code. |
|||
| msg120650 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2010年11月06日 20:30 | |
I believe this is effectively a duplicate of issue 9873. If not, it is still probably more appropriate to add commentary there rather than have a separate bug here. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:08 | admin | set | github: 54552 |
| 2010年11月06日 20:30:03 | r.david.murray | set | status: open -> closed superseder: urllib.parse: Allow bytes in some APIs that use string literals internally nosy: + r.david.murray messages: + msg120650 resolution: duplicate stage: resolved |
| 2010年11月06日 18:52:06 | hfuru | create | |