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

Python 2 Support #9

Closed
lucemia opened this issue May 3, 2018 · 8 comments
Closed

Python 2 Support #9

lucemia opened this issue May 3, 2018 · 8 comments
Labels

Comments

@lucemia
Copy link

lucemia commented May 3, 2018

The 2018.5.1 release will cause exception in python 2.

Downloading https://files.pythonhosted.org/packages/ac/36/80fc1d95cea52f5ff1cc3bbf338c8e1a18388b5b75b0c316f62afdf69e89/django-crequest-2018.5.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-hzETvf/django-crequest/setup.py", line 9, in <module>
        license=open('LICENSE', encoding='utf-8').read(),
    TypeError: 'encoding' is an invalid keyword argument for this function
@asergeant01
Copy link

I'm also seeing this issue

@Alir3z4 Alir3z4 added the bug label May 3, 2018
@Alir3z4
Copy link
Owner

Alir3z4 commented May 3, 2018

This is related to #5
@grafa any comment ?

@lucemia
Copy link
Author

lucemia commented May 3, 2018

There is a trick
from Cheat Sheet: Writing Python 2-3 compatible code - File IO with open()
http://python-future.org/compatible_idioms.html#file-io-with-open

# Python 2 and 3: alternative 1
from io import open
f = open('myfile.txt', 'rb')
data = f.read()              # as bytes
text = data.decode('utf-8')  # unicode, not bytes

# Python 2 and 3: alternative 2
from io import open
f = open('myfile.txt', encoding='utf-8')
text = f.read()    # unicode, not bytes

@Alir3z4
Copy link
Owner

Alir3z4 commented May 4, 2018

@lucemia this is great.
Would be great if you could a make a patch so I can merge and release a cut as soon as possible.

lucemia added a commit to lucemia/django-crequest that referenced this issue May 4, 2018
@lucemia lucemia mentioned this issue May 4, 2018
@Alir3z4
Copy link
Owner

Alir3z4 commented May 8, 2018

This issue seems to be really a case, we have 2 pull request #10 and recent #11 that got closed attempting to fix the issue.

Does this issue actually exists on Python 3 and Python 2 works properly ?
What would be the simple workaround on this ?

I actually never encountered in other packages that I maintain.
For instance have a loot at https://github.com/Alir3z4/html2text/blob/master/setup.py#L12 which reads the README.md for both python2 and python3.

What do you think ?

@lucemia
Copy link
Author

lucemia commented May 9, 2018

'Copyright (c) 2012-2013 Alireza Savand\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0* Redistributions of source code must retain the above copyright\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0notice, this list of conditions and the following disclaimer.\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0* Redistributions in binary form must reproduce the above copyright\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0notice, this list of conditions and the following disclaimer in the\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0documentation and/or other materials provided with the distribution.\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0* Neither the name of the authors nor the\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0names of its contributors may be used to endorse or promote products\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'

I noticed that the LICENSE file contains some unprintable UTF8 characters that cause all the following decode issue. If possible, remove these utf-8 characters will solve the issue.

https://github.com/Alir3z4/django-crequest/blob/master/LICENSE

@asergeant01
Copy link

Could someone review/merge my PR and perform a release?

@Alir3z4
Copy link
Owner

Alir3z4 commented May 11, 2018

I've done it.

Sorry for delay in review and merge.
The pull request has been merged.

Fixed in #12

@Alir3z4 Alir3z4 closed this as completed May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants