[python-win32] UnicodeEncodeError getting Query String Data from ActiveX Scripting engine in classic asp
Mark Hammond
skippy.hammond at gmail.com
Fri Jul 1 06:08:53 CEST 2011
On 1/07/2011 12:57 PM, Chris Lambacher wrote:
...
> Maybe there should be a __unicode__ method on the class? Maybe __str__
> should set an explicit encoding?
>
> Something like:
>
> def __unicode__(self):
> try:
> return unicode(self.__call__())
> except pythoncom.com_error, details:
> if details.hresult not in ERRORS_BAD_CONTEXT:
> raise
> return self.__repr__()
Yeah, that should exist - it does exist for makepy generated objects,
just not dynamic ones. I'll add this.
> def __str__(self):
> return unicode(self).encode('utf-8')
I don't think this is the correct answer though due to the lack of
precedent in other Python objects. Fortunately this all becomes moot in
py3k.
Cheers,
Mark
More information about the python-win32
mailing list