Opened 10 years ago

Closed 10 years ago

#11703 closed (fixed)

Added missing Super calls to 2 widget classes

Reported by: Joshua Russo Owned by: nobody
Component: Forms Version: master
Severity: Keywords: forms widget super multiple-inheritance
Cc: guillermo.gutierrez@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The classes Widget and Textarea were missing the Super calls in their init methods. This could cause problems if someone tries to use them in a scenario with multiple inheritance.

Attachments (2)

form_widgets_super_fix.diff (675 bytes) - added by Joshua Russo 10 years ago.
Added Super calls
fix_rev11491.diff (452 bytes) - added by Guillermo Gutiérrez 10 years ago.

Download all attachments as: .zip

Change History (9)

Changed 10 years ago by Joshua Russo

Attachment: form_widgets_super_fix.diff added

Added Super calls

comment:1 Changed 10 years ago by Chris Beaven

Triage Stage: UnreviewedReady for checkin

Well if we're talking multiple inheritance, all the super calls should be using *args, **kwargs too. But we may as well be consistent at least - accepting.

comment:2 Changed 10 years ago by Luke Plant

Patch needs a bit of work - it should say Textarea not Widget in second hunk, and for Textarea it seems better not to assign to self.attrs twice. I'll do it.

comment:3 Changed 10 years ago by Luke Plant

Resolution: fixed
Status: newclosed

(In [11491]) Fixed #11703: Added missing Super calls to 2 widget classes.

Thanks Rupe

comment:4 Changed 10 years ago by jscott1971@…

Resolution: fixed
Status: closedreopened

I am not sure if this is the right place.

I did an svn update and these are the errors I am getting below.
I reverted back to r11490 and it works again.

Traceback (most recent call last):

File "/usr/lib/python2.6/dist-packages/mod_python/", line 1538, in HandlerDispatch

default=default_handler, arg=req, silent=hlist.silent)

File "/usr/lib/python2.6/dist-packages/mod_python/", line 1230, in _process_target

result = _execute_target(config, req, object, arg)

File "/usr/lib/python2.6/dist-packages/mod_python/", line 1129, in _execute_target

result = object(arg)

File "/usr/lib/python2.6/dist-packages/django/core/handlers/", line 228, in handler

return ModPythonHandler()(req)

File "/usr/lib/python2.6/dist-packages/django/core/handlers/", line 201, in call

response = self.get_response(request)

File "/usr/lib/python2.6/dist-packages/django/core/handlers/", line 134, in get_response

return self.handle_uncaught_exception(request, resolver, exc_info)

File "/usr/lib/python2.6/dist-packages/django/core/handlers/", line 154, in handle_uncaught_exception

return debug.technical_500_response(request, *exc_info)

File "/usr/lib/python2.6/dist-packages/django/views/", line 40, in technical_500_response

html = reporter.get_traceback_html()

File "/usr/lib/python2.6/dist-packages/django/views/", line 114, in get_traceback_html

return t.render(c)

File "/usr/lib/python2.6/dist-packages/django/template/", line 178, in render

return self.nodelist.render(context)

File "/usr/lib/python2.6/dist-packages/django/template/", line 779, in render

bits.append(self.render_node(node, context))

File "/usr/lib/python2.6/dist-packages/django/template/", line 81, in render_node

raise wrapped

TemplateSyntaxError: Caught an exception while rendering: object.init() takes no parameters

Original Traceback (most recent call last):

File "/usr/lib/python2.6/dist-packages/django/template/", line 71, in render_node

result = node.render(context)

File "/usr/lib/python2.6/dist-packages/django/template/", line 87, in render

output = force_unicode(self.filter_expression.resolve(context))

File "/usr/lib/python2.6/dist-packages/django/template/", line 572, in resolve

new_obj = func(obj, *arg_vals)

File "/usr/lib/python2.6/dist-packages/django/template/", line 687, in date

return format(value, arg)

File "/usr/lib/python2.6/dist-packages/django/utils/", line 269, in format

return df.format(format_string)

File "/usr/lib/python2.6/dist-packages/django/utils/", line 30, in format

pieces.append(force_unicode(getattr(self, piece)()))

File "/usr/lib/python2.6/dist-packages/django/utils/", line 175, in r

return self.format('D, j M Y H:i:s O')

File "/usr/lib/python2.6/dist-packages/django/utils/", line 30, in format

pieces.append(force_unicode(getattr(self, piece)()))

File "/usr/lib/python2.6/dist-packages/django/utils/", line 71, in force_unicode

s = unicode(s)

File "/usr/lib/python2.6/dist-packages/django/utils/", line 201, in unicode_cast

return self.func(*self.args,

File "/usr/lib/python2.6/dist-packages/django/utils/translation/", line 62, in ugettext

return real_ugettext(message)

File "/usr/lib/python2.6/dist-packages/django/utils/translation/", line 43, in delayed_loader

return g% caller?(*args, kwargs)

File "/usr/lib/python2.6/dist-packages/django/utils/translation/", line 286, in ugettext

return do_translate(message, 'ugettext')

File "/usr/lib/python2.6/dist-packages/django/utils/translation/", line 276, in do_translate

_default = translation(settings.LANGUAGE_CODE)

File "/usr/lib/python2.6/dist-packages/django/utils/translation/", line 194, in translation

default_translation = _fetch(settings.LANGUAGE_CODE)

File "/usr/lib/python2.6/dist-packages/django/utils/translation/", line 180, in _fetch

app = import_module(appname)

File "/usr/lib/python2.6/dist-packages/django/utils/", line 35, in import_module


File "/usr/lib/python2.6/dist-packages/django/contrib/admin/", line 1, in <module>

from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME

File "/usr/lib/python2.6/dist-packages/django/contrib/admin/", line 13, in <module>

class ActionForm(forms.Form):

File "/usr/lib/python2.6/dist-packages/django/contrib/admin/", line 14, in ActionForm

action = forms.ChoiceField(label=_('Action:'))

File "/usr/lib/python2.6/dist-packages/django/forms/", line 630, in init

help_text, *args, kwargs)

File "/usr/lib/python2.6/dist-packages/django/forms/", line 87, in init

widget = widget()

File "/usr/lib/python2.6/dist-packages/django/forms/", line 395, in init

super(Select, self).init(attrs)

File "/usr/lib/python2.6/dist-packages/django/forms/", line 142, in init

super(Widget, self).init(attrs)

TypeError: object.init() takes no parameters

comment:5 Changed 10 years ago by Guillermo Gutiérrez

Cc: guillermo.gutierrez@… added
Patch needs improvement: set

The same issue here. object.init() takes no parameters, so call it without it.

Changed 10 years ago by Guillermo Gutiérrez

Attachment: fix_rev11491.diff added

comment:6 Changed 10 years ago by Luke Plant

(In [11496]) Fixed Widget.init() for Python 2.6 and greater. Refs #11703

comment:7 Changed 10 years ago by Luke Plant

Patch needs improvement: unset
Resolution: fixed
Status: reopenedclosed

Because of the way object.__init__() works in Python 2.6 and later, classes which inherit from object directly should not call super(...).__init__(), because it can accept no arguments and is pointless.

Note: See TracTickets for help on using tickets.
Back to Top