Skip to content
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

ENH: support SpooledTemporaryFile #44761

Merged
merged 4 commits into from
Dec 11, 2021
Merged

ENH: support SpooledTemporaryFile #44761

merged 4 commits into from
Dec 11, 2021

Conversation

twoertwein
Copy link
Member

@twoertwein twoertwein commented Dec 4, 2021

@@ -935,7 +930,7 @@ def __init__(
self.decode = decode

self.attributes = {}
for attribute in ("seekable", "readable", "writeable"):
Copy link
Member Author

Choose a reason for hiding this comment

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

Should have been "writable" but it seems it was never used as we do not support writing to memory-mapped files.

@twoertwein
Copy link
Member Author

A trimmed down version of this PR could go to 1.3.* as it technically fixes a regression. Let me know whether it should be back-ported or not, based on that I will create a whatsnew for either 1.3 or 1.4.

@jreback
Copy link
Contributor

jreback commented Dec 4, 2021

let's just put in 1.4, trying to avoid backporting anything unless its critical

@jreback jreback added the IO Data IO issues that don't fit into a more specific label label Dec 4, 2021
@twoertwein twoertwein marked this pull request as ready for review December 4, 2021 23:48
@jreback jreback added this to the 1.4 milestone Dec 4, 2021
pandas/io/common.py Outdated Show resolved Hide resolved
@twoertwein
Copy link
Member Author

Thank you for rebasing @jreback, green except for (unrelated?) codecov error.

# seek/read/writ-able.
def __init__(self, buffer: BaseBuffer):
self.buffer = buffer
self.attributes = tuple(
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make these separate properties and just do the check of the buffer inside them? its a bit longer code but should be more obvious what is going on

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, changed it. I made them methods and not properties, as typing.IO defines them as methods:
https://github.com/python/typeshed/blob/1d5857e1e0e0fe6078e563d769f07fe3a3352cc9/stdlib/typing.pyi#L522

Copy link
Contributor

Choose a reason for hiding this comment

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

oh sure

@jreback
Copy link
Contributor

jreback commented Dec 8, 2021

thanks @twoertwein this looks great (yeah a bit longer but way more readable). waiting to merge as i hope some CI patches get us back to green and then can rebase here.

@jreback
Copy link
Contributor

jreback commented Dec 10, 2021

are the windows checks related?

@twoertwein
Copy link
Member Author

It should be unrelated (the test case doesn't seem to open any files). Will rebase and force push to test it again. Cannot reproduce it on linux.

@twoertwein
Copy link
Member Author

twoertwein commented Dec 10, 2021

The error disappeared but I can imagine that it might be related: if mmap fails, opened handles will not be released.

edit: not from this PR but as a result from #44777

@jreback jreback merged commit ecbdfd3 into pandas-dev:master Dec 11, 2021
@jreback
Copy link
Contributor

jreback commented Dec 11, 2021

thanks @twoertwein

@twoertwein twoertwein deleted the IO branch March 9, 2022 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pd.read_csv - encoding argument ignored for SpooledTemporaryFile
3 participants