New submission from Robert Burke <sharpobj...@gmail.com>:

If you create a subclass of set but do not override __or__, __and__, __xor__, 
and __sub__, calling these functions will yield a new instance of your 
subclass.  The new instance will never have __init__ called on it.  Depending 
on what you expect __init__ to do, this can cause problems later on.

The simplest solution would be to make these functions work like list.__add__.  
If you have two instances of some list subclass (foo and bar), 
type(foo.__add__(bar)) will just be list.

----------
files: demo
messages: 133880
nosy: Robert.Burke
priority: normal
severity: normal
status: open
title: __or__, __and__, __sub__, and __xor__ instantiate subclass of set 
without calling __init__
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file21680/demo

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11854>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to