Code

Opened 5 years ago

Closed 5 years ago

#11703 closed (fixed)

Added missing Super calls to 2 widget classes

Reported by: Rupe 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: UI/UX:

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 Rupe 5 years ago.
Added Super calls
fix_rev11491.diff (452 bytes) - added by terrex 5 years ago.

Download all attachments as: .zip

Change History (9)

Changed 5 years ago by Rupe

Added Super calls

comment:1 Changed 5 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready 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 5 years ago by lukeplant

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 5 years ago by lukeplant

  • Resolution set to fixed
  • Status changed from new to closed

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

Thanks Rupe

comment:4 Changed 5 years ago by jscott1971@…

  • Resolution fixed deleted
  • Status changed from closed to reopened

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 Changed 5 years ago by terrex

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

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

Changed 5 years ago by terrex

comment:6 Changed 5 years ago by lukeplant

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

comment:7 Changed 5 years ago by lukeplant

  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from reopened to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.