Inheriting from a builtin strangeness

In python, when inheriting from a builtin, you must be carefull as your object won't follow common rules:

>>> class A(object):
...     def __init__(self, *args, **kwargs):
...         print "%r" % (args,)
...         print "%r" % (kwargs,)
{'prefix': 2}
(3,)
<__main__.A object at ...>

This is normal behavoir: __init__ gets called and do its job at
instantiation time of the class A.

Let's create the exact same class but inheriting from the builtin unicode:

>>> class B(unicode):
...     def __init__(self, *args, **kwargs):
...         print "%r" % (args,)
...         print "%r" % (kwargs,)
...
>>> B(3, prefix=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'prefix' is an invalid keyword argument for this function

Pretty traceback: __init__ of our class do not seem to be called, and because it is inheriting from unicode it seems that C level initialisation is called, bypassing rules of inheritage.

But look at this:

>>> B(3)
{}
(3,)
u'3'

Clearly, our __init__ was called ! probably after the internal init of the builtin. An idea how to check this ?

Anyway, next time, be carefull and do not inherits builtin if you don't know what you are doing.

PS: this was tested on python 2.5