[issue1338] pickling bytes?

2008-04-26 Thread Alexandre Vassalotti

Alexandre Vassalotti [EMAIL PROTECTED] added the comment:

Guido fixed this issue in r61467.

Closing.

--
resolution:  - fixed
status: open - closed

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1338
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1338] pickling bytes?

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Please assign this to me.

I am planning to fix this, along a few other bugs, with my new revision
of the pickle protocol.

--
nosy: +alexandre.vassalotti

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1338
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1338] pickling bytes?

2007-12-01 Thread Georg Brandl

Georg Brandl added the comment:

I added the Developer role to your roundup account, so you can now
assign bugs to yourself. :)

--
assignee:  - alexandre.vassalotti

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1338
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1338] pickling bytes?

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Thank you, Georg!

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1338
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1338] pickling bytes?

2007-10-26 Thread Guido van Rossum

New submission from Guido van Rossum:

Alexandre Vassalotti suggested the following:

A simple way to add specific pickling support for bytes/buffer objects
would be to define two new constants:

 BYTES  = b'\x8c'  # push a bytes object
 BUFFER = b'\x8d'  # push a buffer object

And add the following pickling and unpickling procedures:

 def save_bytes(self, obj, pack=struct.pack):
 n = len(obj)
 self.write(BYTES + pack(i, n) + obj)

 def save_buffer(self, obj, pack=struct.pack):
 n = len(obj)
 self.write(BUFFER + pack(i, n) + obj)

 def load_bytes(self):
 len = mloads(b'i' + self.read(4))
 self.append(self.read(len))

 def load_buffer(self):
 len = mloads(b'i' + self.read(4))
 self.append(buffer(self.read(len)))

The only problem with this approach is that bytes object bigger than
4GB cannot be pickled. Currently, this applies to all string-like
objects, so I don't think this restriction will cause any trouble.
Also, it would be a good idea to bump the protocol version to 3 to
ensure that older Python versions don't try to load pickle streams
created with these new constants.

By the way, would it be a good idea to add specific pickling support
for sets (and frozensets)?

--
keywords: py3k
messages: 56809
nosy: gvanrossum
priority: normal
severity: normal
status: open
title: pickling bytes?
versions: Python 3.0

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1338
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1338] pickling bytes?

2007-10-26 Thread Georg Brandl

Georg Brandl added the comment:

Having explicit support for sets at least would be consistent with all
other types for which there is a display form.

(Or else, {1,2,3} could be a different thing after unpickling if the set
builtin is overwritten.)

--
nosy: +georg.brandl

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1338
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com