[issue19619] Blacklist base64, hex, ... codecs from bytes.decode() and str.encode()

Marc-Andre Lemburg report at bugs.python.org
Sat Nov 16 18:52:41 CET 2013


Marc-Andre Lemburg added the comment:

On 16.11.2013 15:52, Nick Coghlan wrote:
> 
> The only reasonable way to accurately represent "anything that exposes a buffer memoryview can read" as a type check is to write an appropriately duck-typed ABC. You can't enumerate all the types that the binary codecs accept as input, because that list of types isn't finite (unlike the output types, which are far more tightly constrained).

Theoretically, yes. However, in practice, you'd only be interested
in a few type combinations (until the ABC is available).

> I'd also be fine with Serhiy's suggestion of a private "non Unicode codec" set that is maintained by hand and checked *before* the codec operations in the codec methods - that then just becomes an internal implementation detail to improve the efficiency of the output type checks where we have the additional info needed to save the interpreter some work.

For 3.4 that would also do fine :-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19619>
_______________________________________


More information about the Python-bugs-list mailing list