Message202129
| Author |
ncoghlan |
| Recipients |
barry, ezio.melotti, flox, ncoghlan |
| Date |
2013年11月04日.13:20:18 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1383571219.14.0.86891011904.issue17828@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Ah, came up with a relatively simple solution based on an internal helper function with an optional output flag:
>>> import codecs
>>> codecs.encode(b"hello", "bz2_codec").decode("bz2_codec")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'bz2_codec' decoder returned 'bytes' instead of 'str'; use codecs.decode to decode to arbitrary types
>>> "hello".encode("bz2_codec")
TypeError: 'str' does not support the buffer interface
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: invalid input type for 'bz2_codec' codec (TypeError: 'str' does not support the buffer interface)
>>> "hello".encode("rot_13")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'rot_13' encoder returned 'str' instead of 'bytes'; use codecs.encode to encode to arbitrary types |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2013年11月04日 13:20:19 | ncoghlan | set | recipients:
+ ncoghlan, barry, ezio.melotti, flox |
| 2013年11月04日 13:20:19 | ncoghlan | set | messageid: <1383571219.14.0.86891011904.issue17828@psf.upfronthosting.co.za> |
| 2013年11月04日 13:20:19 | ncoghlan | link | issue17828 messages |
| 2013年11月04日 13:20:18 | ncoghlan | create |
|