﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
5256	Python Super and Inheritance is incorrectly written	Trey <trey@…>	Jacob	"Alright, this one nearly drove me mad. In the custom widget section of the documentation:
http://www.djangoproject.com/documentation/newforms/#custom-widgets

There is the following block of code:
{{{
class CommentWidget(forms.TextInput):
    def __init__(self, *args, **kwargs):
        kwargs.setdefault('attrs',{}).update({'size': '40'})
        super(forms.TextInput, self).__init__(*args, **kwargs)
}}}

This seems rather harmless first and in fact works coincidentally most of the time. However in the Python {{{super}}} keyword the current class should be specified instead of the one being inherited from.

Like this:
{{{
class CommentWidget(forms.TextInput):
    def __init__(self, *args, **kwargs):
        kwargs.setdefault('attrs',{}).update({'size': '40'})
        super(CommentWidget, self).__init__(*args, **kwargs)
}}}

I noticed this issue when inheriting from the Select widget. This brings up another argument that most of the Python community thinks the {{{super}}} keyword causes a lot of weird problems and side affects and should be replaced completely in favor of the following syntax.

{{{
class CommentWidget(forms.TextInput):
    def __init__(self, *args, **kwargs):
        kwargs.setdefault('attrs',{}).update({'size': '40'})
        forms.TextInput.__init__(self, *args, **kwargs)
}}}
"		closed	Documentation	dev		fixed			Unreviewed	0	0	0	0	0	0
