Skip to content

BUG: read_csv/table raising when sys.setprofile used #41105

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

Merged
merged 6 commits into from
May 6, 2021

Conversation

mzeitlin11
Copy link
Member

According to https://docs.python.org/3/library/functions.html#locals, locals() should not be modified. AFAICT these are the only places locals() is used in this way without copying.

@mzeitlin11 mzeitlin11 added Bug IO CSV read_csv, to_csv labels Apr 22, 2021
@jreback jreback added this to the 1.3 milestone Apr 22, 2021
@jreback
Copy link
Contributor

jreback commented Apr 22, 2021

good catch.

@jreback jreback merged commit e8a2287 into pandas-dev:master May 6, 2021
@jreback
Copy link
Contributor

jreback commented May 6, 2021

thanks @mzeitlin11

@mzeitlin11 mzeitlin11 deleted the read_csv_profile branch May 6, 2021 15:07
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
parser = all_parsers
data = "a b\n0 1"

sys.setprofile(lambda *a, **k: None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a try/finally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to change - that would be safer

@ansariminhaj
Copy link

With sys.setprofile, read_csv breaks when the data frame is saved using a different separator such as (sep='µ')

df.to_csv('df.csv', index=False, sep='µ')
pd.read_csv('df.csv', sep='µ', engine='python') #setprofile breaks this. separator not recognized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: sys.setprofile breaks read_csv
4 participants