[Python-Dev] Unpickling py2 str as py3 bytes (and vice versa) (original) (raw)

[Python-Dev] Unpickling py2 str as py3 bytes (and vice versa) - implementation (issue #6784)

Guido van Rossum guido at python.org
Sat Mar 17 16:00:21 CET 2012


One reason to use 'bytes' instead of bytes is that it is a string that can be specified e.g. in a config file.

On Sat, Mar 17, 2012 at 7:28 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:

Merlijn van Deen, 17.03.2012 15:20:

On 17 March 2012 10:43, Stefan Behnel wrote:

In lxml, there was an "encoding=unicode" option that would let the XML/HTML/text serialisation function return a Unicode string. This was eventually deprecated in favour of "encoding='unicode'" when ElementTree gained this feature as well some years later.

That's this issue: http://bugs.python.org/issue8047 The thread also suggests the options encoding=False and encoding=None Considering ET uses encoding="unicode" to signal 'don't encode', I agree with you that using encoding="bytes" to signal 'don't encode' would be sensible. However, ET /also/ allows encoding=str.What about allowing both encoding="bytes" /and/ encoding=bytes? It doesn't read well for the unicode type any more because it's gone in Py3 (and "encoding=str" just looks weird). It's less awkward for the bytes type. However, why should there be two ways to do it? Stefan


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

-- --Guido van Rossum (python.org/~guido)



More information about the Python-Dev mailing list