jmcclell / django-bootstrap-pagination

Django template tag for rendering Page objects as Bootstrap pagination HTML
MIT License
212 stars 83 forks source link

python3 compatibility #26

Closed miki725 closed 9 years ago

miki725 commented 9 years ago

this fixes the issue while installing for Python3:

$ pip install django-bootstrap-pagination
Downloading/unpacking django-bootstrap-pagination
  Downloading django-bootstrap-pagination-1.5.0.tar.gz
  Running setup.py (path:/Volumes/Data/Users/miki725/.virtualenvs/test-py3/build/django-bootstrap-pagination/setup.py) egg_info for package django-bootstrap-pagination
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/Volumes/Data/Users/miki725/.virtualenvs/test-py3/build/django-bootstrap-pagination/setup.py", line 26, in <module>
        "License :: OSI Approved :: MIT License",
      File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "<string>", line 14, in replacement_run
      File "/Volumes/Data/Users/miki725/.virtualenvs/test-py3/lib/python3.4/site-packages/setuptools/command/egg_info.py", line 322, in write_pkg_info
        metadata.write_pkg_info(cmd.egg_info)
      File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 1108, in write_pkg_info
        self.write_pkg_file(pkg_info)
      File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 1129, in write_pkg_file
        long_desc = rfc822_escape(self.get_long_description())
      File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/util.py", line 470, in rfc822_escape
        lines = header.split('\n')
    TypeError: Type str doesn't support the buffer API
    Complete output from command python setup.py egg_info:
    running egg_info

creating pip-egg-info/django_bootstrap_pagination.egg-info

writing dependency_links to pip-egg-info/django_bootstrap_pagination.egg-info/dependency_links.txt

writing pip-egg-info/django_bootstrap_pagination.egg-info/PKG-INFO

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/Volumes/Data/Users/miki725/.virtualenvs/test-py3/build/django-bootstrap-pagination/setup.py", line 26, in <module>

    "License :: OSI Approved :: MIT License",

  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/core.py", line 148, in setup

    dist.run_commands()

  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 955, in run_commands

    self.run_command(cmd)

  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 974, in run_command

    cmd_obj.run()

  File "<string>", line 14, in replacement_run

  File "/Volumes/Data/Users/miki725/.virtualenvs/test-py3/lib/python3.4/site-packages/setuptools/command/egg_info.py", line 322, in write_pkg_info

    metadata.write_pkg_info(cmd.egg_info)

  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 1108, in write_pkg_info

    self.write_pkg_file(pkg_info)

  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py", line 1129, in write_pkg_file

    long_desc = rfc822_escape(self.get_long_description())

  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/util.py", line 470, in rfc822_escape

    lines = header.split('\n')

TypeError: Type str doesn't support the buffer API

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Volumes/Data/Users/miki725/.virtualenvs/test-py3/build/django-bootstrap-pagination
Storing debug log for failure in /Volumes/Data/Users/miki725/.pip/pip.log
jmcclell commented 9 years ago

I would be surprised if installation is the only issue you run into.

I would really like to maintain backwards compatibility with 2.x if possible, as well. There are have been several other forks where people have changed things here and there, but I haven't seen someone verify that they've got it fully working under 3.x yet nor anyone who has made changes in a backwards compatible way.

I'm not against doing a major revision bump for 3.x support, though.

Have you ran into any other issues in 3.x yet?

miki725 commented 9 years ago

Forgot to push another Py3 fix. Just added it. These were the two issues I came across on Py3.4 and Django1.7. Also tested on Py2.7 and did not came across any other issues.

miki725 commented 9 years ago

here is by the way an example of why the second issue was breaking in Py3:

>>> list(range(1, 23/5))
Traceback (most recent call last):
  File "<ipython-input-3-0dd73305fd86>", line 1, in <module>
    list(range(1, 23/5))
TypeError: 'float' object cannot be interpreted as an integer

>>> list(range(1, 23//5))
[1, 2, 3]

EDIT: as for both 2.7 and 3.X compatibility, // is valid perfectly valid in Python2 (docs) so these changes are both Py2 and Py3 compatible

gfairchild commented 9 years ago

I'd love to see this PR get accepted.

jmcclell commented 9 years ago

I didn't merge it because I thought there would be more to come for full 3.x support, but since all of these changes are fully backwards compatible to 2.7 i'll merge.