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
Change History
comment:1 Changed 3 years ago by cboos
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@…>
Changed 3 years ago by osimons
- Attachment t8160-baseexception_message-r8311-0.11.diff added
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: ↓ 9 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: ↓ 10 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
- Attachment t8160-baseexception_message-r8332-0.11.diff added
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: ↓ 13 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...



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