Blobs are subclassable

Bug #127182 reported by Jim Fulton
2
Affects Status Importance Assigned to Milestone
ZODB
Status tracked in 3.9
3.8
Fix Released
Low
Christian Theune
3.9
Fix Released
Low
Christian Theune

Bug Description

Blobs do not support subclassing, but people are tempted to subclass them.

At a minimum we need to make very explicit in their documentation that subclassing isn't supported. It might be worthwhile going further, Marius suggested raising an error in __init__ if self is of the wrong class. That should be easy and might provide adequate protection.

Changed in zodb:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Christian Theune (ctheune) wrote :

Letting Sebastian handle this.

Changed in zodb:
assignee: nobody → sw-gocept
Changed in zodb:
status: Confirmed → In Progress
Revision history for this message
Sebastian Wehrmann (sw-gocept) wrote :

I've worked on this. Here is my patch.
Can somebody have a look on this, please?

Revision history for this message
Jim Fulton (jim-zope) wrote : Re: [Bug 127182] Re: Blobs are subclassable

This looks fine, although I don't like the extra indirection through
_init_state. I'd rather just have __init__ call the original
__setstate__.

Jim

On Sep 6, 2007, at 5:10 AM, Sebastian Wehrmann wrote:

> I've worked on this. Here is my patch.
> Can somebody have a look on this, please?
>
> ** Attachment added: "C:\Users\sweh\Desktop\bug127182.patch"
> http://launchpadlibrarian.net/9146563/C%3A%5CUsers%5Csweh%
> 5CDesktop%5Cbug127182.patch
>
> --
> Blobs are subclassable
> https://bugs.launchpad.net/bugs/127182
> You received this bug notification because you are a direct subscriber
> of the bug.

--
Jim Fulton mailto:<email address hidden> Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org

Revision history for this message
Sebastian Wehrmann (sw-gocept) wrote :

Jim Fulton wrote:
> This looks fine, although I don't like the extra indirection through
> _init_state. I'd rather just have __init__ call the original
> __setstate__.
>
Should I change it or leave it?

--
Sebastian Wehrmann

gocept gmbh & co. kg · forsterstrasse 29 · 06112 halle/saale
www.gocept.com · work. +49 345 122988912 · fax. +49 345 12298891

Revision history for this message
Jim Fulton (jim-zope) wrote :

On Sep 6, 2007, at 10:25 AM, Sebastian Wehrmann wrote:

> Jim Fulton wrote:
>> This looks fine, although I don't like the extra indirection through
>> _init_state. I'd rather just have __init__ call the original
>> __setstate__.
>>
> Should I change it or leave it?

I don't feel strongly about it. I'd prefer that you change it, but I
can do it later if it really bugs me. :)

Thanks for working on this!

Jim

--
Jim Fulton mailto:<email address hidden> Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org

Revision history for this message
Sebastian Wehrmann (sw-gocept) wrote :

Ok, here another patch with code Jim might prefer.

Now someone privileged should decide, which one to check-in :)

Regards,
  Sebastian

Revision history for this message
Sebastian Wehrmann (sw-gocept) wrote :

Me again,

there was a little typo in a comment, changed atomically to automatically. Don't ask me why.

Switched it back.

Sorry for this.

Revision history for this message
Christian Theune (ctheune) wrote :

Am Donnerstag, den 06.09.2007, 18:13 +0000 schrieb Sebastian Wehrmann:
> Me again,
>
> there was a little typo in a comment, changed atomically to
> automatically. Don't ask me why.
>
> Switched it back.
>
> Sorry for this.

I think you got caught up with the method signature of __init__().

It doesn't need a "state" argument and can simply pass "None" to
__setstate__.

Christian

Revision history for this message
Sebastian Wehrmann (sw-gocept) wrote :

Christian, your right. Here the corrected version.

Revision history for this message
Jim Fulton (jim-zope) wrote :

On Sep 7, 2007, at 1:12 AM, Sebastian Wehrmann wrote:

> Christian, your right. Here the corrected version.

Looks good. Thanks again.

Jim

--
Jim Fulton mailto:<email address hidden> Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org

Revision history for this message
Christian Theune (ctheune) wrote :

Applying Basti's patch.

Changed in zodb:
assignee: sw-gocept → ct-gocept
Revision history for this message
Christian Theune (ctheune) wrote :

Fix on trunk means released.

Revision history for this message
Christian Theune (ctheune) wrote :

released in b4

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.