Modify

Opened 10 years ago

Closed 7 years ago

#11991 closed defect (fixed)

RegistrationError cannot initialize on Python 2.4

Reported by: Jun Omae Owned by: Steffen Hoffmann
Priority: normal Component: AccountManagerPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

Unit tests fail with Trac 0.12.5 on Python 2.4. super() function only works for new-style classes. TracError class is not a new-style class on Python 2.4.

$ PYTHONPATH=. ~/venv/trac/0.12.5/bin/python acct_mgr/tests/__init__.py --skip-functional-tests
..........................................................E.EEE.EE.E..EE.
======================================================================
ERROR: test_check_error (acct_mgr.tests.register.DummyRegInspectorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/accountmanagerplugin.git/acct_mgr/tests/register.py", line 90, in test_check_error
    self.check.validate_registration(self.req)
  File "/home/jun66j5/src/accountmanagerplugin.git/acct_mgr/tests/register.py", line 61, in validate_registration
    raise RegistrationError('Dummy check error')
  File "/home/jun66j5/src/accountmanagerplugin.git/acct_mgr/register.py", line 50, in __init__
    super(RegistrationError, self).__init__(message, title, show_traceback)
TypeError: super() argument 1 must be type, not classobj
....

----------------------------------------------------------------------
Ran 73 tests in 2.780s

FAILED (errors=9)
  • acct_mgr/register.py

    diff --git a/acct_mgr/register.py b/acct_mgr/register.py
    index 5008350..8d15e2c 100644
    a b class RegistrationError(TracError): 
    4747        tb = 'show_traceback'
    4848        # Care for the 2nd TracError standard keyword argument only.
    4949        show_traceback = tb in kwargs and kwargs.pop(tb, False)
    50         super(RegistrationError, self).__init__(message, title, show_traceback)
     50        TracError.__init__(self, message, title, show_traceback)
    5151        self.msg_args = args
    5252
    5353

Attachments (0)

Change History (3)

comment:1 Changed 9 years ago by Steffen Hoffmann

In 14273:

AccountManagerPlugin: Remove super() on TracError class for Python2.4 compatibility, refs #11991.

Thanks to Jun Omae, who not only reported corresponding (unit) test results
but provided a clear explanation and suggested the fix right away as well.

comment:2 Changed 9 years ago by Steffen Hoffmann

Status: newaccepted

comment:3 Changed 7 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Steffen Hoffmann.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.