Re: enhancement request: make py3 read/write py2 pickle format

2015-06-11 Thread Serhiy Storchaka
On 11.06.15 02:58, Chris Angelico wrote: On Thu, Jun 11, 2015 at 8:10 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: The problem is that there are two different ways repr might write out a dict equal to {'a': 1, 'b': 2}. This can make tests brittle -- e.g. it's why doctest fails badly at

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-11 Thread Steven D'Aprano
On Thursday 11 June 2015 15:39, Devin Jeanpierre wrote: But I'm not talking about re-inventing what already exists. If I want JSON, I'll use JSON, not spend weeks or months re-writing it from scratch. I can't do this: class MyClass: pass a = MyClass() serialised = repr(a) b =

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Chris Angelico
On Wed, Jun 10, 2015 at 9:04 PM, Neal Becker ndbeck...@gmail.com wrote: I believe a good native serialization system is essential for any modern programming language. If pickle isn't it, we need something else that can serialize all language objects. Or, are you saying, it's impossible to do

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Robert Kern
On 2015-06-10 12:04, Neal Becker wrote: Chris Warrick wrote: On Tue, Jun 9, 2015 at 8:08 PM, Neal Becker ndbeck...@gmail.com wrote: One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Neal Becker
Chris Warrick wrote: On Tue, Jun 9, 2015 at 8:08 PM, Neal Becker ndbeck...@gmail.com wrote: One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use pickle format for data storage. It

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Marko Rauhamaa
Robert Kern robert.k...@gmail.com: By the very nature of the stated problem: serializing all language objects. Being able to construct any object, including instances of arbitrary classes, means that arbitrary code can be executed. All I have to do is make a pickle file for an object that

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Steven D'Aprano
On Wednesday 10 June 2015 14:48, Devin Jeanpierre wrote: [...] and literal_eval is not a great idea. * the common serializer (repr) does not output a canonical form, and can serialize things in a way that they can't be deserialized For literals, the canonical form is that understood by

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread random832
On Wed, Jun 10, 2015, at 08:08, Marko Rauhamaa wrote: You can't serialize/migrate arbitrary objects. Consider open TCP connections, open files and other objects that extend outside the Python VM. Also objects hold references to each other, leading to a huge reference mesh. For example:

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Robert Kern
On 2015-06-10 13:08, Marko Rauhamaa wrote: Robert Kern robert.k...@gmail.com: By the very nature of the stated problem: serializing all language objects. Being able to construct any object, including instances of arbitrary classes, means that arbitrary code can be executed. All I have to do is

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Irmen de Jong
On 10-6-2015 11:36, Steven D'Aprano wrote: For most apps, the alternatives are better. Irmen's serpent library is strictly better on every front, for example. (Except potentially security, who knows.) Beyond simple needs, like rc files, literal_eval is not sufficient. You can't use it to

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
FWIW most of the objections below also apply to JSON, so this doesn't just have to be about repr/literal_eval. I'm definitely a huge proponent of widespread use of something like protocol buffers, both for production code and personal hacky projects. On Wed, Jun 10, 2015 at 2:36 AM, Steven

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Gregory Ewing
Robert Kern wrote: To allow people to write their own types that can be serialized, you have to let them specify arbitrary callables that will do the reconstruction. If you whitelist the possible reconstruction callables, you have greatly restricted the types that can participate in the

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
On Wed, Jun 10, 2015 at 4:39 PM, Devin Jeanpierre jeanpierr...@gmail.com wrote: On Wed, Jun 10, 2015 at 4:25 PM, Terry Reedy tjre...@udel.edu wrote: On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: The problem is that there are two different ways repr might write out a dict equal to {'a': 1,

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Chris Angelico
On Thu, Jun 11, 2015 at 8:10 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: The problem is that there are two different ways repr might write out a dict equal to {'a': 1, 'b': 2}. This can make tests brittle -- e.g. it's why doctest fails badly at examples involving dictionaries. Text

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Terry Reedy
On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: The problem is that there are two different ways repr might write out a dict equal to {'a': 1, 'b': 2}. This can make tests brittle Not if one compares objects rather than string representations of objects. I am strongly of the view that code

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Terry Reedy
On 6/10/2015 7:39 PM, Devin Jeanpierre wrote: On Wed, Jun 10, 2015 at 4:25 PM, Terry Reedy tjre...@udel.edu wrote: On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: The problem is that there are two different ways repr might write out a dict equal to {'a': 1, 'b': 2}. This can make tests brittle

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
On Wed, Jun 10, 2015 at 4:46 PM, Terry Reedy tjre...@udel.edu wrote: On 6/10/2015 7:39 PM, Devin Jeanpierre wrote: On Wed, Jun 10, 2015 at 4:25 PM, Terry Reedy tjre...@udel.edu wrote: On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: The problem is that there are two different ways repr might

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread random832
On Wed, Jun 10, 2015, at 19:30, Gregory Ewing wrote: If whitelisting a type is the *only* thing you need to do to make it serialisable, I think that comes close enough to the stated goal of being able to serialise all [potentially serialisable] language objects. IMO the serialization

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
On Wed, Jun 10, 2015 at 4:25 PM, Terry Reedy tjre...@udel.edu wrote: On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: The problem is that there are two different ways repr might write out a dict equal to {'a': 1, 'b': 2}. This can make tests brittle Not if one compares objects rather than

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
Snipped aplenty. On Wed, Jun 10, 2015 at 8:21 PM, Steven D'Aprano st...@pearwood.info wrote: On Thu, 11 Jun 2015 08:10 am, Devin Jeanpierre wrote: [...] I could spend a bunch of time writing yet another config file format, or I could use text format protocol buffers, YAML, or TOML and call it

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Steven D'Aprano
On Thu, 11 Jun 2015 08:10 am, Devin Jeanpierre wrote: [...] For literals, the canonical form is that understood by Python. I'm pretty sure that these have been stable since the days of Python 1.0, and will remain so pretty much forever: The problem is that there are two different ways repr

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Marko Rauhamaa
Devin Jeanpierre jeanpierr...@gmail.com: For example, one can also imagine testing that a serialized structure is identical across version changes, so that it's guaranteed to be forwards/backwards compatible. It is not enough to test that the deserialized form is, because it might differ

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Mark Lawrence
On 09/06/2015 19:08, Neal Becker wrote: One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use pickle format for data storage. It certainly would be a big help if py3 could read/write py2

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Chris Warrick
On Tue, Jun 9, 2015 at 8:08 PM, Neal Becker ndbeck...@gmail.com wrote: One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use pickle format for data storage. It certainly would be a big help

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Laura Creighton
In a message of Tue, 09 Jun 2015 14:08:25 -0400, Neal Becker writes: One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use pickle format for data storage. It certainly would be a big help if

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Zachary Ware
On Tue, Jun 9, 2015 at 1:08 PM, Neal Becker ndbeck...@gmail.com wrote: One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use pickle format for data storage. It certainly would be a big help

enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Neal Becker
One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use pickle format for data storage. It certainly would be a big help if py3 could read/write py2 pickle format. You know, backward

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Serhiy Storchaka
On 09.06.15 21:31, Laura Creighton wrote: We have an issue about that. https://bugs.python.org/issue13566 Go there and say you want it too. :) I afraid issue title is too general. :) The issue is only about one minor detail of py3 to py2 compatibility. --

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Serhiy Storchaka
On 09.06.15 21:08, Neal Becker wrote: One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use pickle format for data storage. It certainly would be a big help if py3 could read/write py2 pickle

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Devin Jeanpierre
There's a lot of subtle issues with pickle compatibility. e.g. old-style vs new-style classes. It's kinda hard and it's better to give up. I definitely agree it's better to use something else instead. For example, we switched to using protocol buffers, which have much better compatibility

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Chris Angelico
On Wed, Jun 10, 2015 at 6:07 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: There's a lot of subtle issues with pickle compatibility. e.g. old-style vs new-style classes. It's kinda hard and it's better to give up. I definitely agree it's better to use something else instead. For example,

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Irmen de Jong
On 10-6-2015 1:06, Chris Angelico wrote: On Wed, Jun 10, 2015 at 6:07 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: There's a lot of subtle issues with pickle compatibility. e.g. old-style vs new-style classes. It's kinda hard and it's better to give up. I definitely agree it's better to

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Devin Jeanpierre
Passing around data that can be put into ast.literal_eval is synonymous with passing around data taht can be put into eval. It sounds like a trap. Other points against JSON / etc.: the lack of schema makes it easier to stuff anything in there (not as easily as pickle, mind), and by returning a

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Chris Angelico
On Wed, Jun 10, 2015 at 10:47 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: Passing around data that can be put into ast.literal_eval is synonymous with passing around data taht can be put into eval. It sounds like a trap. Except that it's hugely restricted. There are JSON parsing

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Steven D'Aprano
On Wednesday 10 June 2015 13:57, random...@fastmail.us wrote: On Tue, Jun 9, 2015, at 23:52, Steven D'Aprano wrote: For human readable serialized data, text format protocol buffers are seriously underrated. (Relatedly: underdocumented, too.) Ironically, literal_eval is designed to process

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Steven D'Aprano
On Wednesday 10 June 2015 10:47, Devin Jeanpierre wrote: Passing around data that can be put into ast.literal_eval is synonymous with passing around data taht can be put into eval. It sounds like a trap. In what way? literal_eval will cleanly and safely refuse to evaluate strings like:

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread random832
On Tue, Jun 9, 2015, at 23:52, Steven D'Aprano wrote: For human readable serialized data, text format protocol buffers are seriously underrated. (Relatedly: underdocumented, too.) Ironically, literal_eval is designed to process text-format protocols using human-readable Python syntax for

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Devin Jeanpierre
On Tue, Jun 9, 2015 at 8:52 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wednesday 10 June 2015 10:47, Devin Jeanpierre wrote: Passing around data that can be put into ast.literal_eval is synonymous with passing around data taht can be put into eval. It sounds like a

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Chris Angelico
On Wed, Jun 10, 2015 at 1:57 PM, random...@fastmail.us wrote: On Tue, Jun 9, 2015, at 23:52, Steven D'Aprano wrote: For human readable serialized data, text format protocol buffers are seriously underrated. (Relatedly: underdocumented, too.) Ironically, literal_eval is designed to process