[Pyobjc-dev] NSError.localizedDescription() and Application Bundles
Brought to you by:
ronaldoussoren
From: Jean-Pierre <cho...@fr...> - 2009-07-11 09:31:02
|
Hello, I am having problems to get the localized error message from an NSError object. The following code runs fine when launched as a simple script in the Terminal: from Foundation import * url = NSURL.URLWithString_("http://invalid") request = NSURLRequest.requestWithURL_(url) (data, response, error)= NSURLConnection.sendSynchronousRequest_returningResponse_error_(request) NSLog("error:%@", error.localizedDescription()) print unicode(error.localizedDescription()) But fails with an UnicodeError Exception: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\u2019' in position 3: ordinal not in range(128) when ran from a Cocoa-Python Application project from Xcode. The error string has indeed an non ascii character in its fourth position ("can’t find host"), but the type of the error.localizedDescription() object is objc.pyobjc_unicode so it shouldn't be a problem. Am I doing something wrong ? Thanks, - Jean-Pierre. |