Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Fix using file instead of io.IOBase #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

martin2250
Copy link

As mentioned in #126

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@martin2250
Copy link
Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@fahhem
Copy link
Contributor

fahhem commented Dec 6, 2018

This is not backwards-compatible with Python 2. Please check against file if available. Some options are mentioned here:
https://stackoverflow.com/questions/25738602/how-to-judge-a-file-type-both-work-in-python-2-and-python-3

@martin2250
Copy link
Author

Which method do you think is better in this case, using the tuple and try/except or checking hasattr(f, 'fileno') / hasattr(f, 'write')?

@fahhem
Copy link
Contributor

fahhem commented Dec 6, 2018

I think fileno() is a good proxy because it supports file-like objects better (like sockets, etc)

@coveralls
Copy link

coveralls commented Dec 8, 2018

Coverage Status

Coverage increased (+0.3%) to 43.893% when pulling 2ead78a on martin2250:master into d9b94b2 on google:master.

@martin2250
Copy link
Author

Ok, the PR should be good now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants