Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Python 3 support #339

Closed
jleclanche opened this Issue · 13 comments
@jleclanche

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

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.

@coagulant

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
@jezdez jezdez reopened this
@jezdez
Owner

Woops, sorry.

@relic-

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

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?

@w-diesel

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

@SalmanPK

+1 Waiting for this :(

@paunin

+1!!!

@Depado

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

@TheBB

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

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

@jpic

Maybe you could do a pull request ?

@aaugustin
Owner

Closing is favor of #412.

@aaugustin aaugustin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.