Opened 15 years ago

Closed 15 years ago

#11703 closed (fixed)

Added missing Super calls to 2 widget classes

Reported by: Joshua Russo Owned by: nobody
Component: Forms Version: dev
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

Description

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 15 years ago.
Added Super calls
fix_rev11491.diff (452 bytes ) - added by Guillermo Gutiérrez 15 years ago.

Download all attachments as: .zip

Change History (9)

by Joshua Russo, 15 years ago

Attachment: form_widgets_super_fix.diff added

Added Super calls

comment:1 by Chris Beaven, 15 years ago

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 by Luke Plant, 15 years ago

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 by Luke Plant, 15 years ago

Resolution: fixed
Status: newclosed

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

Thanks Rupe

comment:4 by jscott1971@…, 15 years ago

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/importer.py", line 1538, in HandlerDispatch

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

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

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

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

result = object(arg)

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

return ModPythonHandler()(req)

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

response = self.get_response(request)

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

return self.handle_uncaught_exception(request, resolver, exc_info)

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

return debug.technical_500_response(request, *exc_info)

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

html = reporter.get_traceback_html()

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

return t.render(c)

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

return self.nodelist.render(context)

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

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

File "/usr/lib/python2.6/dist-packages/django/template/debug.py", 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/debug.py", line 71, in render_node

result = node.render(context)

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

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

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

new_obj = func(obj, *arg_vals)

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

return format(value, arg)

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

return df.format(format_string)

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

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

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

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

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

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

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

s = unicode(s)

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

return self.func(*self.args, self.kw)

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

return real_ugettext(message)

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

return g% caller(*args, kwargs)

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

return do_translate(message, 'ugettext')

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

_default = translation(settings.LANGUAGE_CODE)

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

default_translation = _fetch(settings.LANGUAGE_CODE)

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

app = import_module(appname)

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

import(name)

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

from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME

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

class ActionForm(forms.Form):

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

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

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

help_text, *args, kwargs)

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

widget = widget()

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

super(Select, self).init(attrs)

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

super(Widget, self).init(attrs)

TypeError: object.init() takes no parameters

comment:5 by Guillermo Gutiérrez, 15 years ago

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

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

by Guillermo Gutiérrez, 15 years ago

Attachment: fix_rev11491.diff added

comment:6 by Luke Plant, 15 years ago

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

comment:7 by Luke Plant, 15 years ago

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