Edgewall Software
Modify

Ticket #8160 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

DeprecationWarnings with Python 2.6

Reported by: Felix Schwarz <felix.schwarz@…> Owned by: osimons
Priority: low Milestone: 0.11.5
Component: general Version: 0.11-stable
Severity: trivial Keywords:
Cc: felix.schwarz@…
Release Notes:
API Changes:

Description

Every time a TracError is instantiated, Python 2.6 raises a DeprecationWarning? because direct access to the message attribute is considered deprecated:

.../trac_0.11dev/trac/core.py:36: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
    self.message = message

Attachments

t8160-baseexception_message-r8311-0.11.diff (599 bytes) - added by osimons 3 years ago.
Keep 'message' using property.
t8160-baseexception_message-r8332-0.11.diff (615 bytes) - added by cboos 3 years ago.
slightly more compact version using lambdas

Download all attachments as: .zip

Change History

comment:1 Changed 3 years ago by cboos

jonas already fixed that for 0.11.1 IIRC, then reverted the fix. What was the reason again?

comment:2 Changed 3 years ago by kamil@…

I can confirm this on openSUSE 11.1 with Trac 0.11.4

comment:3 Changed 3 years ago by Felix Schwarz <felix.schwarz@…>

  • Cc felix.schwarz@… added

comment:4 Changed 3 years ago by Felix Schwarz <felix.schwarz@…>

Fix was in r7774, revert is r7775.

Changed 3 years ago by osimons

Keep 'message' using property.

comment:5 Changed 3 years ago by osimons

Just spotted some advice from Brett Cannon suggesting using a property in order to keep the deprecated 'message' when subclassing Exception. Tested a quick patch that seems to work for 2.4 and 2.6.

comment:6 Changed 3 years ago by osimons

  • Owner set to osimons

I suppose I can look after this one. Testing welcome.

comment:7 follow-up: Changed 3 years ago by cboos

Using lambdas could make it a one liner.

comment:8 Changed 3 years ago by cboos

(or two ;-) )

But otherwise, looks good.

comment:9 in reply to: ↑ 7 ; follow-up: Changed 3 years ago by osimons

Replying to cboos:

Using lambdas could make it a one liner.

Really? I actually tried that before submitting the patch, but I got an error saying it would not allow assignment in lambda. I just thought 'hmm' and reverted back to the explicit version. Are you sure? Could well be my mistake, of course :-)

Changed 3 years ago by cboos

slightly more compact version using lambdas

comment:10 in reply to: ↑ 9 Changed 3 years ago by cboos

Replying to osimons:

... I actually tried that before submitting the patch, but I got an error saying it would not allow assignment in lambda.

Indeed, but think functional ;-)

comment:11 follow-up: Changed 3 years ago by osimons

  • Milestone changed from 0.11.6 to 0.11.5

Ah, I see. Looks like we have a clear winner in this round of "Know-Your-Python"...

comment:12 Changed 3 years ago by osimons

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

Thanks, committed in [8333:8334].

comment:13 in reply to: ↑ 11 Changed 3 years ago by rblank

Replying to osimons:

Ah, I see. Looks like we have a clear winner in this round of "Know-Your-Python"...

FWIW, I still find the non-setattr setter clearer. Not that it really matters...

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from osimons. Next status will be 'closed'
Author


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

 
Note: See TracTickets for help on using tickets.