This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients alexandre.vassalotti, georg.brandl, gvanrossum, ygale
Date 2007-10-25.22:48:58
SpamBayes Score 0.11621407
Marked as misclassified No
Message-id <ca471dc20710251548u294dd25am1b174e95c67ed0a0@mail.gmail.com>
In-reply-to <1193314140.09.0.314444594945.issue1286@psf.upfronthosting.co.za>
Content
2007/10/25, Yitz Gale <report@bugs.python.org>:
> I was actually bitten badly by this issue with
> StringIO. I added fileinput only as an afterthought.
>
> In an xml.sax app, I needed seek() support for a
> codec-wrapped file handle, so I over-wrapped it with
> StringIO. The result was that I had to refactor code all over
> the place to handle StringIO as a special case. What a
> mess!

I don't understand. What did your code look like after the refactoring?

I find that typically a useful idiom is to have one piece of code
handle opening/closing of streams and let the rest of the code just
deal with streams without ever closing them. E.g.

f = open(filename)
try:
  process(f)
finally:
  f.close()

or, if you want:

with open(filename) as f:
  process(f)

As I don't understand how you are working the StringIO() call into
this I'm still not sure what the issue is.

> Why is this getting over-excited? It's a very
> lightweight change. You can't beat the cost/benefit ratio.

Until you submit a patch it's more work for me. :-)
History
Date User Action Args
2007-10-25 22:48:59gvanrossumsetspambayes_score: 0.116214 -> 0.11621407
recipients: + gvanrossum, georg.brandl, ygale, alexandre.vassalotti
2007-10-25 22:48:59gvanrossumlinkissue1286 messages
2007-10-25 22:48:58gvanrossumcreate