to_bytes(u"URL") --> 'URL'.
(url)
| 1087 | |
| 1088 | |
| 1089 | def _to_bytes(url): |
| 1090 | """to_bytes(u"URL") --> 'URL'.""" |
| 1091 | # Most URL schemes require ASCII. If that changes, the conversion |
| 1092 | # can be relaxed. |
| 1093 | # XXX get rid of to_bytes() |
| 1094 | if isinstance(url, str): |
| 1095 | try: |
| 1096 | url = url.encode("ASCII").decode() |
| 1097 | except UnicodeError: |
| 1098 | raise UnicodeError("URL " + repr(url) + |
| 1099 | " contains non-ASCII characters") |
| 1100 | return url |
| 1101 | |
| 1102 | |
| 1103 | def unwrap(url): |
no test coverage detected