On Wed, Mar 20, 2013 at 12:29 PM, Chris Nighswonger <
cnighswon...@foundations.edu> wrote:

> On Tue, Mar 19, 2013 at 2:58 PM, Stefan Seifert <n...@detonation.org>wrote:
>
>>  Ok, that would not work, since this is just some Perl trickery and
>> nothing
>> really gets written to any file handle.
>> But you can use just the same trick in Python:
>>
>>
> This is probably a question for another list, so feel free to say so.
>
> The example supplied worked exactly. However, when implement the same
> technique using the Python library I need I get such as this:
>
> exceptions.AttributeError: 'cStringIO.StringO' object has no attribute
> 'encoding' at line blah.
>

I finally located the problem which I'll post just for completeness.

Some code in the Python lib was checking the 'encoding' attribute of the
stdout object. Per the Python manual, cStringIO objects have no settable
attributes:

"Since this is a factory function which returns objects of built-in types,
there’s no way to build your own version using subclassing. It’s not
possible to set attributes on it. Use the original StringIO module in those
cases."[1]

Using the StringIO module allowed me to set the 'encoding' attribute which
fixed things.

Thanks again for the kind assistance.

Chris


[1] http://docs.python.org/2/library/stringio.html#module-cStringIO

Reply via email to