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

Update to handle in-memory filelike objects #46

Merged
merged 5 commits into from
Nov 9, 2021

Conversation

ffreemt
Copy link
Contributor

@ffreemt ffreemt commented Oct 3, 2020

Handle in-memory file-like objects

tests added:

  • test_get_filelike.py (net image)
  • test_load_png_filelike in test_get.py (file-like object created from local image file)

setup.py Outdated
@@ -23,6 +23,7 @@
py_modules=['imagesize'],
test_suite='test',
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
install_requires=['requests',],

Choose a reason for hiding this comment

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

We only need requests for tests, right? So that should probably be in tests_require rather than install_requires

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I switched to urllib.request and got rid of requests altogether. Also, hasattr(filepath, "read") is changed to isinstance(filepath, io.BytesIO) for better checking of a file-like object in 2756936

Choose a reason for hiding this comment

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

Ah, yes, that's probably a good change. Something supporting read() might not also support seek() and such, after all. Though the idea of duck-typing it is nice

ffreemt and others added 3 commits October 13, 2020 12:07
…) in imagesize.py, requests.get to urllib.request.urlopen in test/test_get_filelike.py [requsets package no longer needed]
@shibukawa shibukawa merged commit cde3224 into shibukawa:master Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants