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

2012-03-13 Thread Merlijn van Deen
http://bugs.python.org/issue6784 ("byte/unicode pickle incompatibilities between python2 and python3") Hello all, Currently, pickle unpickles python2 'str' objects as python3 'str' objects, where the encoding to use is passed to the Unpickler. However, there are cases where it makes more sense to

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

2012-03-13 Thread Merlijn van Deen
Oops. I should re-read my mails before I send them, not /after/ I send them. On 13 March 2012 12:44, Merlijn van Deen wrote: pickled = BytestrPickler(data, bytestr=True); unpickled = BytestrUnpickler(data, bytestr=True) should of course read pickled = BytestrPickler(data); unpic

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

2012-03-13 Thread Michael Foord
On 13 Mar 2012, at 04:44, Merlijn van Deen wrote: > http://bugs.python.org/issue6784 ("byte/unicode pickle > incompatibilities between python2 and python3") > > Hello all, > > Currently, pickle unpickles python2 'str' objects as python3 'str' > objects, where the encoding to use is passed to th

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

2012-03-13 Thread Guido van Rossum
On Tue, Mar 13, 2012 at 12:42 PM, Michael Foord wrote: > > On 13 Mar 2012, at 04:44, Merlijn van Deen wrote: > >> http://bugs.python.org/issue6784 ("byte/unicode pickle >> incompatibilities between python2 and python3") >> >> Hello all, >> >> Currently, pickle unpickles python2 'str' objects as py

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

2012-03-13 Thread Merlijn van Deen
On 13 March 2012 22:13, Guido van Rossum wrote: > Well, since trying to migrate data between versions using pickle is > the "wrong" thing anyway, I think the status quo is just fine. > Developers doing the "right" thing don't use pickle for this purpose. I'm confused by this. "The pickle serializ

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

2012-03-13 Thread Guido van Rossum
On Tue, Mar 13, 2012 at 2:50 PM, Merlijn van Deen wrote: > On 13 March 2012 22:13, Guido van Rossum wrote: >> Well, since trying to migrate data between versions using pickle is >> the "wrong" thing anyway, I think the status quo is just fine. >> Developers doing the "right" thing don't use pickl

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

2012-03-13 Thread Nick Coghlan
On Wed, Mar 14, 2012 at 8:08 AM, Guido van Rossum wrote: > If you can solve your problem with a suitably hacked Unpickler > subclass that's fine with me, but I would personally use this > opportunity to change the app to some other serialization format that > is perhaps less general but more robus

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

2012-03-15 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/13/2012 06:49 PM, Nick Coghlan wrote: > On Wed, Mar 14, 2012 at 8:08 AM, Guido van Rossum > wrote: >> If you can solve your problem with a suitably hacked Unpickler >> subclass that's fine with me, but I would personally use this >> opportunit

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

2012-03-16 Thread Guido van Rossum
On Thu, Mar 15, 2012 at 9:48 PM, Tres Seaver wrote: > On 03/13/2012 06:49 PM, Nick Coghlan wrote: >> On Wed, Mar 14, 2012 at 8:08 AM, Guido van Rossum >> wrote: >>> If you can solve your problem with a suitably hacked Unpickler >>> subclass that's fine with me, but I would personally use this >>>

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

2012-03-16 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/16/2012 10:57 AM, Guido van Rossum wrote: > On Thu, Mar 15, 2012 at 9:48 PM, Tres Seaver > wrote: >> On 03/13/2012 06:49 PM, Nick Coghlan wrote: >>> On Wed, Mar 14, 2012 at 8:08 AM, Guido van Rossum >>> wrote: If you can solve your problem

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

2012-03-16 Thread Guido van Rossum
On Fri, Mar 16, 2012 at 9:20 AM, Tres Seaver wrote: > On 03/16/2012 10:57 AM, Guido van Rossum wrote: >> On Thu, Mar 15, 2012 at 9:48 PM, Tres Seaver >> wrote: >>> On 03/13/2012 06:49 PM, Nick Coghlan wrote: On Wed, Mar 14, 2012 at 8:08 AM, Guido van Rossum wrote: > If you can solv

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

2012-03-16 Thread Merlijn van Deen
Hi Guido, Let me start with thanking you for your long reply. It has clarified some points to me, but I am still not certain about some others. I hope I can clarify why I'm confused about this issue in the following. First of all, let me clarify that I wrote my original mail not as 'the guy who w

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

2012-03-16 Thread Guido van Rossum
OK, how about using encoding=bytes (yes, the type object!)? Or 'bytes' ? --Guido van Rossum (sent from Android phone) On Mar 16, 2012 2:19 PM, "Merlijn van Deen" wrote: > Hi Guido, > > Let me start with thanking you for your long reply. It has clarified > some points to me, but I am still not ce

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

2012-03-17 Thread Merlijn van Deen
On 17 March 2012 00:57, Guido van Rossum wrote: > OK, how about using encoding=bytes (yes, the type object!)? Or 'bytes' ? encoding=bytes makes (at least intuitive) sense to me; encoding='bytes' would imply there is an encoding with name 'bytes' that somehow does b''.decode('bytes')=b'', and woul

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

2012-03-17 Thread Stefan Behnel
Guido van Rossum, 17.03.2012 00:57: > OK, how about using encoding=bytes (yes, the type object!)? Or 'bytes' ? 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='uni

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

2012-03-17 Thread Merlijn van Deen
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 y

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

2012-03-17 Thread Stefan Behnel
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 ElementT

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

2012-03-17 Thread Guido van Rossum
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 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" o

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

2012-03-17 Thread Serhiy Storchaka
17.03.12 17:00, Guido van Rossum написав(ла): One reason to use 'bytes' instead of bytes is that it is a string that can be specified e.g. in a config file. Thus, there are no reasons to use bytes instead of 'bytes'. ___ Python-Dev mailing list Pytho

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

2012-03-17 Thread Merlijn van Deen
On 17 March 2012 16:28, Serhiy Storchaka wrote: > Thus, there are no reasons to use bytes instead of 'bytes'. Aesthetics ;-) I've implemented the encoding="bytes" version [1]. Thank you all for your input! Merlijn [1] http://bugs.python.org/issue6784#msg156166 __