After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 606224 - Exceptions do not return unicode data
Exceptions do not return unicode data
Status: RESOLVED FIXED
Product: LDTP
Classification: Other
Component: pyldtp
unspecified
Other Linux
: Normal normal
: ---
Assigned To: LDTP maintainers
LDTP Development Mailing List
Depends on:
Blocks:
 
 
Reported: 2010-01-06 16:51 UTC by James Tatum
Modified: 2010-02-05 02:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Update exceptions to use standard base exception class (1.34 KB, patch)
2010-01-06 16:52 UTC, James Tatum
committed Details | Review
Update exception handlers that use .value to use str() (59.60 KB, patch)
2010-01-06 16:52 UTC, James Tatum
committed Details | Review

Description James Tatum 2010-01-06 16:51:38 UTC
I was having a problem passing a unicode string to LdtpExecutionError:

import ldtp

try:
    raise ldtp.LdtpExecutionError(u"testraise\u221a")
except Exception, e:
    print unicode(e)

The exceptions in LDTP seem to be copied from examples in the Python documentation for overriding exceptions. Resultantly, they store the message in a variable called value rather than in the args variable like the base class. This wouldn't be a problem except that the base class has its own __unicode__ method which depends on the args variable, so calling unicode() on an LDTP exception returns a null string. 

Changing exceptions to just use the Exception class as-is resolves this issue. The attached patch also makes LDTP exceptions inherit from ldtp.Error so all LDTP exceptions can be caught by catching ldtp.Error. I think this was the original design philosophy but it wasn't implemented.

There were quite a few places where an exception handler used LdtpExecutionError.value - these are updated in the 0002 patch.
Comment 1 James Tatum 2010-01-06 16:52:21 UTC
Created attachment 150907 [details] [review]
Update exceptions to use standard base exception class
Comment 2 James Tatum 2010-01-06 16:52:48 UTC
Created attachment 150908 [details] [review]
Update exception handlers that use .value to use str()
Comment 3 Nagappan Alagappan 2010-02-05 02:50:08 UTC
James, Thanks for the bug report and patch. Its fixed in git.
Comment 4 Nagappan Alagappan 2010-02-05 02:50:52 UTC
Review of attachment 150907 [details] [review]:

Thanks for the patch
Comment 5 Nagappan Alagappan 2010-02-05 02:51:09 UTC
Review of attachment 150908 [details] [review]:

Thanks for the patch