Python 3 support #339

Closed
jleclanche opened this Issue Nov 30, 2012 · 13 comments

Comments

Projects
None yet

I searched the issues and didn't see any about the status of python 3 support.

Here are the current errors on pip install (on 22ebebd) when running in a 1.5 python3 environment:

Installing collected packages: django-debug-toolbar
  Running setup.py install for django-debug-toolbar

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/management/commands/debugsqlshell.py", line 17
        print sqlparse.format(raw_sql, reindent=True),
                     ^
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/toolbar/loader.py", line 96
        except ImportError, e:
                          ^
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/utils/sqlparse/lexer.py", line 82
        except Exception, err:
                        ^
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/utils/sqlparse/sql.py", line 155
        print '%s%s%d %s \'%s\'' % (indent, pre, idx,
                               ^
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/utils/tracking/__init__.py", line 40
        except Exception, e:
                        ^
    SyntaxError: invalid syntax

      File "/home/adys/.local/share/virtualenvs/wewow/lib/python3.3/site-packages/debug_toolbar/__init__.py", line 6
        except Exception, e:
                        ^
    SyntaxError: invalid syntax

rafales commented Dec 3, 2012

We should start discussion about python 3 support.

Supported python versions

There is no information about which python versions does django-debug-toolbar support. The most important question is if we can drop support for versions lower than 2.6. Supporting python 2.5 would make it painful (eg. except syntax).

Supported django versions

Django 1.4.2 comes with django.utils.six and some additional compatibility code for python 3 support. Question is - can we drop support for django < 1.4.2, or we should use external six library? Also, it is possible that we would have to include a bit more compatibility code.

I believe, python 2.5 can be dropped, as django is dropping it in 1.5.
Dropping django < 1.4.2 support is arguable, but I'd prefer movig forward, because python 2 will eventually become history.

@jezdez jezdez closed this Mar 2, 2013

@jezdez jezdez reopened this Mar 2, 2013

Owner

jezdez commented Mar 2, 2013

Woops, sorry.

relic- commented Mar 4, 2013

I have been testing debug toolbar under python 3 , so far after running it through 2to3 not a lot of issues during usage, except sqlpanel injection and some tests failed after 2to3 as well (mostly related to tracking injection).
Because in Python 3 unbound methods are just functions, _debug_toolbar.utils.replace_function does not work properly.
My temporary fix was smth like:

def _replace_function(func, wrapped, klass=None):
    if getattr(klass, func.__name__, None):
        setattr(klass, func.__name__, wrapped)
    elif isinstance(func, types.FunctionType):
    ....

Not very nice but did the trick, as far as I could find, there seems to be no way to get class from unbound method.
Hopefully I am missing something.

Some backwards compatibility code will be required but technically if we drop django < 1.4.2 it should be no problem.
Although, I don't want to drop python 2.5, as it breaks compatibility with older versions of django.
(Someone might be running 1.4.* with python 2.5)

I don't mind a separate/future version, that works with same Python versions as django 1.5 (2.6,2.7,3.2, 3.3) thus supports only 1.5

weholt commented Mar 14, 2013

Can anybody please tell me if they have a at least partially working port of django-debug-toolbar for Python 3? And if so can I have a copy?

Contributor

w-diesel commented Apr 25, 2013

If anyone is interested, please take a look at #373

SalmanPK commented Jun 4, 2013

+1 Waiting for this :(

@ghost

ghost commented Aug 4, 2013

+1

paunin commented Aug 20, 2013

+1!!!

Depado commented Sep 3, 2013

Is there a way I can get your debug toolbar working with Python3 ? =)

TheBB commented Sep 11, 2013

To those waiting for Python 3 support: I have been using this fork with no issues.

https://github.com/elvard/django-debug-toolbar

Member

jpic commented Sep 27, 2013

Maybe you could do a pull request ?

Contributor

aaugustin commented Oct 17, 2013

Closing is favor of #412.

@aaugustin aaugustin closed this Oct 17, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment