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

check for file type/class fails in python3 #18

Open
raymondnijssen opened this issue Jun 13, 2018 · 2 comments
Open

check for file type/class fails in python3 #18

raymondnijssen opened this issue Jun 13, 2018 · 2 comments

Comments

@raymondnijssen
Copy link

Already read that this library has not been fully tested in python3.

When using a POST request, there is a check for the file type here:
https://github.com/boundlessgeo/lib-qgis-commons/blob/1d93089fe95957ad9f6c87f037ee07196a0af640/qgiscommons2/network/networkaccessmanager.py#L222

That does not work in python3. A solution/workaround can be found here:
https://stackoverflow.com/questions/36320953/isinstance-file-python-2-7-and-3-5

I tried this and it works for me:

import io
try:
    file_types = (file, io.IOBase)
except NameError:
    file_types = (io.IOBase,)

with open("README.md", "r") as fin:
    print(isinstance(fin, file_types))

Should I do a pull request?

@volaya
Copy link
Contributor

volaya commented Jul 9, 2018

Sorry for not replying earlier, hadn't seen this.

I will make the change, no need for a PR

Thanks!

@raymondnijssen
Copy link
Author

Thank you! 👍

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

No branches or pull requests

2 participants