Closed Bug 569664 Opened 15 years ago Closed 14 years ago

DeprecationWarning in py2.6, exception.message

Categories

(Add-on SDK Graveyard :: General, defect)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: warner, Assigned: nassimian.joseph)

Details

Attachments

(1 file, 1 obsolete file)

A python2.6 user on #jetpack noticed that, when running "cfx testall" on a windows box, the MOZRUNNER_BIN_NOT_FOUND error message also provoked a DeprecationWarning. It seems that python2.6 has deprecated the use of the ".message" attribute on exceptions. This is used in cuddlefish/__init__.py run(), at the very end of the file, around line 563.

 /Users/warner/stuff/mozilla/jetpack/jetpack-sdk/trunk/python-lib/cuddlefish/__init__.py:563: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6

I guess the fix is to look at .args instead, or maybe using str(e) . I've never used .message, so I don't know what it's defined to contain.

A simple way to reproduce this is: "cfx -b /tmp/MISSING testall":
The Add-on SDK is no longer a Mozilla Labs experiment and has become a big enough project to warrant its own Bugzilla product, so the "Add-on SDK" product has been created for it, and I am moving its bugs to that product.

To filter bugmail related to this change, filter on the word "looptid".
Component: Jetpack SDK → General
Product: Mozilla Labs → Add-on SDK
QA Contact: jetpack-sdk → general
Version: Trunk → unspecified
I got the deprecated warning as well, although it doesn't hinder the execution, it will help by making the console a bit more readable.

Not sure about who's supposed to review this, by looking around online, my best bet was Drew Willcoxon <adw@mozilla.com>.
Attachment #506246 - Flags: review?(adw)
Comment on attachment 506246 [details] [diff] [review]
a patch that replaces the deprecated code

Thanks for the patch!  It works.  I'm not a Python guru, but looking at the docs [1,2] and the way Mozrunner constructs the exception [3], I think that calling str() on this exception should work OK on both 2.5 and 2.6.

(FWIW I couldn't reproduce the warning or this specific Mozrunner exception using the step in comment 0.  When you provide a binary path via -b, Runner.find_binary() isn't called, and it's find_binary that raises this exception.  I changed python-lib/mozrunner/__init__.py to unconditionally call find_binary to test this patch.)

[1] http://docs.python.org/release/2.5.4/lib/module-exceptions.html
[2] http://docs.python.org/release/2.6.6/library/exceptions.html
[3] https://github.com/mozilla/addon-sdk/blob/0f9e14ea9d9f3251cbe925e2b69facd31376be8a/python-lib/mozrunner/__init__.py#L423
Attachment #506246 - Flags: review?(adw) → review+
Assignee: nobody → nassimian.joseph
Status: NEW → ASSIGNED
This is Joe's patch rebased on the correct file (the original patch has a hardcoded filename) and with Joe's name added to the credits list.

The tree is currently frozen for the 1.0b2 release, but I'll land it when it thaws later today.
Attachment #506246 - Attachment is obsolete: true
Attachment #506424 - Flags: review+
Yup, str(e) is the best way to get that string.. since filing this bug, I've seen lots of other python programs move from "e.message" to "str(e)".
The tree thawed today, and I landed the patch here:

https://github.com/mozilla/addon-sdk/commit/b491b3980aa2d0ae008ccbfafb8c7c19b026e5fd

Thanks again!
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.0b3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: