Skip to content

CLN: StringIO from io instead of from StringIO #10470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kawochen opened this issue Jun 29, 2015 · 8 comments
Closed

CLN: StringIO from io instead of from StringIO #10470

kawochen opened this issue Jun 29, 2015 · 8 comments
Labels
Compat pandas objects compatability with Numpy or Python functions
Milestone

Comments

@kawochen
Copy link
Contributor

It looks like io is available from 2.6 onward. Can I move the importing out of compat (and replaces any cStringIO with StringIO)? StringIO.StringIO doesn't always do the same thing as io.StringIO.

@jreback
Copy link
Contributor

jreback commented Jun 29, 2015

cStringIO is aliased to StringIO so this shouldn't be any differnt

@kawochen
Copy link
Contributor Author

Yes, in Python 3 they are aliases. In Python 2 the cStringIO and StringIO modules are used, but I believe io is available for all versions of Python supported. In particular #10369 is reproducible only in Python 2 because of the difference between StringIO.StringIO and io.StringIO

@jreback
Copy link
Contributor

jreback commented Jun 29, 2015

they are also aliased in py2 on purpose

where is io.stringio different? do u have a reference

@kawochen
Copy link
Contributor Author

The only thing I'm aware of other than performance is the input allowed. StringIO.StringIO strs input, so it accepts [], None, {} and anything it can convert, whereas io.StringIO accepts unicode and None. And I need to correct myself because the issue I referenced calls StringIO.StringIO on Python 2 and io.BytesIO (not io.StringIO) on Python 3.

StringIO.StringIO(None).getvalue() returns 'None'
io.StringIO(None).getvalue() returns u''
StringIO.StringIO({}).getvalue() returns '{}'
io.StringIO({}).getvalue() raises

@shoyer
Copy link
Member

shoyer commented Jun 29, 2015

Indeed, seems like a good idea to use io.StringIO or io.BytesIO.

@jreback The io module was basically a backport from Python 3 to Python 2:
https://docs.python.org/2/library/io.html

@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Jul 2, 2015
@jreback
Copy link
Contributor

jreback commented Jul 2, 2015

@kawochen so nothing against this, if it passes the current suite prob ok. Though these edge cases may not be tested, so if you can gin up something where StringIO.StringIO(...) fails and io.StringIO(...) passes would be good as well

@jreback
Copy link
Contributor

jreback commented Jan 7, 2016

@kawochen ahh good point.

@jreback jreback added this to the Next Major Release milestone Jan 7, 2016
@jorisvandenbossche
Copy link
Member

The compat version has been removed (#25954), so this can be closed.

@jorisvandenbossche jorisvandenbossche modified the milestones: Contributions Welcome, 0.25.0 Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

No branches or pull requests

4 participants