You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tricky. I only solution I can think of is replacing cStringIO with
_stringio or just refusing to replace StringIO usage once cStringIO has
been seen. The latter seems like the best solutions.
loewis commented on Jan 10, 2009
loewismannequin
MannequinAuthor
More actions
If there is no straight-forward solution, we should close it as "won't
fix", and encourage users to work around.
Ok. I will close this for now. This is a very common construct; if we
get more bug reports, we can reconsider. (I'm attaching the patch I used
to "fix" this for future reference.)
Activity
loewis commentedon Jan 10, 2009
The fragment
try:
import cStringIO as StringIO
except ImportError:
import StringIO
s=StringIO.StringIO()
gets rewritten to
try:
import io as StringIO
except ImportError:
import io
s=io.StringIO()
Unfortunately, that code fails to work: the first import succeeds,
actually binding StringIO; the name io is unbound and gives NameError.
Apparently, the fixer choses to replace all occurrences of StringIO with
io; it should extend this replacement to "as" clauses.
My work-around is to import as _StringIO in both cases, and then refer
to the module as _StringIO.
benjaminp commentedon Jan 10, 2009
Tricky. I only solution I can think of is replacing cStringIO with
_stringio or just refusing to replace StringIO usage once cStringIO has
been seen. The latter seems like the best solutions.
loewis commentedon Jan 10, 2009
If there is no straight-forward solution, we should close it as "won't
fix", and encourage users to work around.
benjaminp commentedon Jan 10, 2009
Ok. I will close this for now. This is a very common construct; if we
get more bug reports, we can reconsider. (I'm attaching the patch I used
to "fix" this for future reference.)