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

python3.2 support #254

Closed
brianmay opened this issue Aug 19, 2014 · 1 comment
Closed

python3.2 support #254

brianmay opened this issue Aug 19, 2014 · 1 comment

Comments

@brianmay
Copy link
Contributor

Hello,

With this one line patch, the tests work under Python 3.2:

Index: django-guardian-1.2.4/guardian/models.py
===================================================================
--- django-guardian-1.2.4.orig/guardian/models.py       2014-08-19 10:46:03.875700385 +1000
+++ django-guardian-1.2.4/guardian/models.py    2014-08-19 10:46:25.363209417 +1000
@@ -26,7 +26,7 @@
         abstract = True

     def __unicode__(self):
-        return u'%s | %s | %s' % (
+        return '%s | %s | %s' % (
             unicode(self.content_object),
             unicode(getattr(self, 'user', False) or self.group),
             unicode(self.permission.codename))

The top of this file has:

from __future__ import unicode_literals

So there is no need to use u'...' syntax anywhere, it will do the right thing anyway.

@brianmay
Copy link
Contributor Author

Hello,

Unfortunately this change is insufficient. I noticed this when I filled ticket #283, but I did not notice that this ticket wasn't documented sufficiently. When run from Python3, the unicode method will never be called.

For best solution, see: https://docs.djangoproject.com/en/dev/topics/python3/#str-and-unicode-methods

Thanks

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

1 participant