Skip to content

Conditional import of StringIO from StringIO or cStringIO doesn't work #1169

Closed
@gvanrossum

Description

@gvanrossum

This code:

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

doesn't work: it complains error: Name 'StringIO' already defined on the second import. I think this is because in cStringIO, the function StringIO is an overloaded function (returning different types with and without argument) while in StringIO.py there is a class StringIO.

I'm not sure how to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions