Commit 4c5c5d00eba6fd4f02cf0ebae90c81f5fd19377d

Authored by Claude Paroz
1 parent 18ecbd6e

Removed support for Python 2

@@ -2,8 +2,6 @@ dist: xenial @@ -2,8 +2,6 @@ dist: xenial
2 language: python 2 language: python
3 matrix: 3 matrix:
4 include: 4 include:
5 - - python: 2.7  
6 - env: TOXENV=py27-django111  
7 - python: 3.4 5 - python: 3.4
8 env: TOXENV=py34-django111 6 env: TOXENV=py34-django111
9 - python: 3.4 7 - python: 3.4
@@ -3,6 +3,11 @@ @@ -3,6 +3,11 @@
3 History 3 History
4 ======= 4 =======
5 5
  6 +X.Y.Z (YYYY-MM-DD)
  7 +------------------
  8 +
  9 +* Removed support for Python 2.
  10 +
6 1.9.2 (2019-12-03) 11 1.9.2 (2019-12-03)
7 ------------------ 12 ------------------
8 13
1 -from __future__ import unicode_literals  
2 -  
3 from django.conf import settings 1 from django.conf import settings
4 from django.contrib.contenttypes.fields import GenericForeignKey 2 from django.contrib.contenttypes.fields import GenericForeignKey
5 from django.contrib.contenttypes.models import ContentType 3 from django.contrib.contenttypes.models import ContentType
@@ -8,7 +6,6 @@ from django.db import models @@ -8,7 +6,6 @@ from django.db import models
8 from django.urls import reverse 6 from django.urls import reverse
9 from django.utils import timezone 7 from django.utils import timezone
10 from django.utils.translation import gettext_lazy as _ 8 from django.utils.translation import gettext_lazy as _
11 -from six import python_2_unicode_compatible  
12 9
13 from .managers import CommentManager 10 from .managers import CommentManager
14 11
@@ -45,7 +42,6 @@ class BaseCommentAbstractModel(models.Model): @@ -45,7 +42,6 @@ class BaseCommentAbstractModel(models.Model):
45 ) 42 )
46 43
47 44
48 -@python_2_unicode_compatible  
49 class CommentAbstractModel(BaseCommentAbstractModel): 45 class CommentAbstractModel(BaseCommentAbstractModel):
50 """ 46 """
51 A user comment about some object. 47 A user comment about some object.
@@ -90,7 +86,7 @@ class CommentAbstractModel(BaseCommentAbstractModel): @@ -90,7 +86,7 @@ class CommentAbstractModel(BaseCommentAbstractModel):
90 def save(self, *args, **kwargs): 86 def save(self, *args, **kwargs):
91 if self.submit_date is None: 87 if self.submit_date is None:
92 self.submit_date = timezone.now() 88 self.submit_date = timezone.now()
93 - super(CommentAbstractModel, self).save(*args, **kwargs) 89 + super().save(*args, **kwargs)
94 90
95 def _get_userinfo(self): 91 def _get_userinfo(self):
96 """ 92 """
1 -from __future__ import unicode_literals  
2 -  
3 from django.contrib import admin 1 from django.contrib import admin
4 from django.contrib.auth import get_user_model 2 from django.contrib.auth import get_user_model
5 from django.utils.translation import gettext_lazy as _, ngettext 3 from django.utils.translation import gettext_lazy as _, ngettext
@@ -8,7 +6,7 @@ from django_comments import get_model @@ -8,7 +6,7 @@ from django_comments import get_model
8 from django_comments.views.moderation import perform_flag, perform_approve, perform_delete 6 from django_comments.views.moderation import perform_flag, perform_approve, perform_delete
9 7
10 8
11 -class UsernameSearch(object): 9 +class UsernameSearch:
12 """The User object may not be auth.User, so we need to provide 10 """The User object may not be auth.User, so we need to provide
13 a mechanism for issuing the equivalent of a .filter(user__username=...) 11 a mechanism for issuing the equivalent of a .filter(user__username=...)
14 search in CommentAdmin. 12 search in CommentAdmin.
@@ -43,7 +41,7 @@ class CommentsAdmin(admin.ModelAdmin): @@ -43,7 +41,7 @@ class CommentsAdmin(admin.ModelAdmin):
43 actions = ["flag_comments", "approve_comments", "remove_comments"] 41 actions = ["flag_comments", "approve_comments", "remove_comments"]
44 42
45 def get_actions(self, request): 43 def get_actions(self, request):
46 - actions = super(CommentsAdmin, self).get_actions(request) 44 + actions = super().get_actions(request)
47 # Only superusers should be able to delete the comments from the DB. 45 # Only superusers should be able to delete the comments from the DB.
48 if not request.user.is_superuser and 'delete_selected' in actions: 46 if not request.user.is_superuser and 'delete_selected' in actions:
49 actions.pop('delete_selected') 47 actions.pop('delete_selected')
@@ -10,7 +10,7 @@ class LatestCommentFeed(Feed): @@ -10,7 +10,7 @@ class LatestCommentFeed(Feed):
10 10
11 def __call__(self, request, *args, **kwargs): 11 def __call__(self, request, *args, **kwargs):
12 self.site = get_current_site(request) 12 self.site = get_current_site(request)
13 - return super(LatestCommentFeed, self).__call__(request, *args, **kwargs) 13 + return super().__call__(request, *args, **kwargs)
14 14
15 def title(self): 15 def title(self):
16 return _("%(site_name)s comments") % dict(site_name=self.site.name) 16 return _("%(site_name)s comments") % dict(site_name=self.site.name)
@@ -30,7 +30,7 @@ class CommentSecurityForm(forms.Form): @@ -30,7 +30,7 @@ class CommentSecurityForm(forms.Form):
30 if initial is None: 30 if initial is None:
31 initial = {} 31 initial = {}
32 initial.update(self.generate_security_data()) 32 initial.update(self.generate_security_data())
33 - super(CommentSecurityForm, self).__init__(data=data, initial=initial, **kwargs) 33 + super().__init__(data=data, initial=initial, **kwargs)
34 34
35 def security_errors(self): 35 def security_errors(self):
36 """Return just those errors associated with security""" 36 """Return just those errors associated with security"""
1 -# -*- coding: utf-8 -*-  
2 -from __future__ import unicode_literals  
3 -  
4 from django.db import models, migrations 1 from django.db import models, migrations
5 from django.conf import settings 2 from django.conf import settings
6 3
1 -# -*- coding: utf-8 -*-  
2 -from __future__ import unicode_literals  
3 -  
4 from django.db import models, migrations 1 from django.db import models, migrations
5 2
6 3
1 -# -*- coding: utf-8 -*-  
2 -from __future__ import unicode_literals  
3 -  
4 from django.db import models, migrations 1 from django.db import models, migrations
5 2
6 3
@@ -2,7 +2,6 @@ from django.conf import settings @@ -2,7 +2,6 @@ from django.conf import settings
2 from django.db import models 2 from django.db import models
3 from django.utils import timezone 3 from django.utils import timezone
4 from django.utils.translation import gettext_lazy as _ 4 from django.utils.translation import gettext_lazy as _
5 -from six import python_2_unicode_compatible  
6 5
7 from .abstracts import ( 6 from .abstracts import (
8 COMMENT_MAX_LENGTH, BaseCommentAbstractModel, CommentAbstractModel, 7 COMMENT_MAX_LENGTH, BaseCommentAbstractModel, CommentAbstractModel,
@@ -14,7 +13,6 @@ class Comment(CommentAbstractModel): @@ -14,7 +13,6 @@ class Comment(CommentAbstractModel):
14 db_table = "django_comments" 13 db_table = "django_comments"
15 14
16 15
17 -@python_2_unicode_compatible  
18 class CommentFlag(models.Model): 16 class CommentFlag(models.Model):
19 """ 17 """
20 Records a flag on a comment. This is intentionally flexible; right now, a 18 Records a flag on a comment. This is intentionally flexible; right now, a
@@ -59,4 +57,4 @@ class CommentFlag(models.Model): @@ -59,4 +57,4 @@ class CommentFlag(models.Model):
59 def save(self, *args, **kwargs): 57 def save(self, *args, **kwargs):
60 if self.flag_date is None: 58 if self.flag_date is None:
61 self.flag_date = timezone.now() 59 self.flag_date = timezone.now()
62 - super(CommentFlag, self).save(*args, **kwargs) 60 + super().save(*args, **kwargs)
@@ -86,7 +86,7 @@ class NotModerated(Exception): @@ -86,7 +86,7 @@ class NotModerated(Exception):
86 pass 86 pass
87 87
88 88
89 -class CommentModerator(object): 89 +class CommentModerator:
90 """ 90 """
91 Encapsulates comment-moderation options for a given model. 91 Encapsulates comment-moderation options for a given model.
92 92
@@ -257,7 +257,7 @@ class CommentModerator(object): @@ -257,7 +257,7 @@ class CommentModerator(object):
257 send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True) 257 send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)
258 258
259 259
260 -class Moderator(object): 260 +class Moderator:
261 """ 261 """
262 Handles moderation of a set of models. 262 Handles moderation of a set of models.
263 263
1 -from __future__ import absolute_import  
2 -  
3 from django import http 1 from django import http
4 from django.apps import apps 2 from django.apps import apps
5 from django.conf import settings 3 from django.conf import settings
@@ -24,7 +22,7 @@ class CommentPostBadRequest(http.HttpResponseBadRequest): @@ -24,7 +22,7 @@ class CommentPostBadRequest(http.HttpResponseBadRequest):
24 """ 22 """
25 23
26 def __init__(self, why): 24 def __init__(self, why):
27 - super(CommentPostBadRequest, self).__init__() 25 + super().__init__()
28 if settings.DEBUG: 26 if settings.DEBUG:
29 self.content = render_to_string("comments/400-debug.html", {"why": why}) 27 self.content = render_to_string("comments/400-debug.html", {"why": why})
30 28
1 -from __future__ import absolute_import  
2 -  
3 from django.contrib.auth.decorators import login_required, permission_required 1 from django.contrib.auth.decorators import login_required, permission_required
4 from django.contrib.sites.shortcuts import get_current_site 2 from django.contrib.sites.shortcuts import get_current_site
5 from django.shortcuts import get_object_or_404, render 3 from django.shortcuts import get_object_or_404, render
@@ -3,11 +3,7 @@ A few bits of helper functions for comment views. @@ -3,11 +3,7 @@ A few bits of helper functions for comment views.
3 """ 3 """
4 4
5 import textwrap 5 import textwrap
6 -  
7 -try:  
8 - from urllib.parse import urlencode  
9 -except ImportError: # Python 2  
10 - from urllib import urlencode 6 +from urllib.parse import urlencode
11 7
12 from django.http import HttpResponseRedirect 8 from django.http import HttpResponseRedirect
13 from django.shortcuts import render, resolve_url 9 from django.shortcuts import render, resolve_url
@@ -87,7 +87,7 @@ field:: @@ -87,7 +87,7 @@ field::
87 87
88 def get_comment_create_data(self, **kwargs): 88 def get_comment_create_data(self, **kwargs):
89 # Use the data of the superclass, and add in the title field 89 # Use the data of the superclass, and add in the title field
90 - data = super(CommentFormWithTitle, self).get_comment_create_data(**kwargs) 90 + data = super().get_comment_create_data(**kwargs)
91 data['title'] = self.cleaned_data['title'] 91 data['title'] = self.cleaned_data['title']
92 return data 92 return data
93 93
@@ -33,7 +33,6 @@ setup( @@ -33,7 +33,6 @@ setup(
33 'License :: OSI Approved :: BSD License', 33 'License :: OSI Approved :: BSD License',
34 'Operating System :: OS Independent', 34 'Operating System :: OS Independent',
35 'Programming Language :: Python', 35 'Programming Language :: Python',
36 - 'Programming Language :: Python :: 2.7',  
37 'Programming Language :: Python :: 3', 36 'Programming Language :: Python :: 3',
38 'Programming Language :: Python :: 3.6', 37 'Programming Language :: Python :: 3.6',
39 'Programming Language :: Python :: 3.7', 38 'Programming Language :: Python :: 3.7',
@@ -3,13 +3,9 @@ Comments may be attached to any object. See the comment documentation for @@ -3,13 +3,9 @@ Comments may be attached to any object. See the comment documentation for
3 more information. 3 more information.
4 """ 4 """
5 5
6 -from __future__ import unicode_literals  
7 -  
8 from django.db import models 6 from django.db import models
9 -from six import python_2_unicode_compatible  
10 7
11 8
12 -@python_2_unicode_compatible  
13 class Author(models.Model): 9 class Author(models.Model):
14 first_name = models.CharField(max_length=30) 10 first_name = models.CharField(max_length=30)
15 last_name = models.CharField(max_length=30) 11 last_name = models.CharField(max_length=30)
@@ -18,7 +14,6 @@ class Author(models.Model): @@ -18,7 +14,6 @@ class Author(models.Model):
18 return '%s %s' % (self.first_name, self.last_name) 14 return '%s %s' % (self.first_name, self.last_name)
19 15
20 16
21 -@python_2_unicode_compatible  
22 class Article(models.Model): 17 class Article(models.Model):
23 author = models.ForeignKey(Author, on_delete=models.CASCADE) 18 author = models.ForeignKey(Author, on_delete=models.CASCADE)
24 headline = models.CharField(max_length=100) 19 headline = models.CharField(max_length=100)
@@ -27,7 +22,6 @@ class Article(models.Model): @@ -27,7 +22,6 @@ class Article(models.Model):
27 return self.headline 22 return self.headline
28 23
29 24
30 -@python_2_unicode_compatible  
31 class Entry(models.Model): 25 class Entry(models.Model):
32 title = models.CharField(max_length=250) 26 title = models.CharField(max_length=250)
33 body = models.TextField() 27 body = models.TextField()
1 -from __future__ import absolute_import  
2 -  
3 from django.contrib.auth.models import User 1 from django.contrib.auth.models import User
4 from django.contrib.contenttypes.models import ContentType 2 from django.contrib.contenttypes.models import ContentType
5 from django.contrib.sites.models import Site 3 from django.contrib.sites.models import Site
1 -from __future__ import absolute_import  
2 -  
3 from django.core.exceptions import ImproperlyConfigured 1 from django.core.exceptions import ImproperlyConfigured
4 from django.test.utils import modify_settings, override_settings 2 from django.test.utils import modify_settings, override_settings
5 3
1 -from __future__ import absolute_import  
2 -  
3 import time 1 import time
4 2
5 from django.conf import settings 3 from django.conf import settings
@@ -15,7 +13,7 @@ from testapp.models import Article @@ -15,7 +13,7 @@ from testapp.models import Article
15 class CommentFormTests(CommentTestCase): 13 class CommentFormTests(CommentTestCase):
16 14
17 def setUp(self): 15 def setUp(self):
18 - super(CommentFormTests, self).setUp() 16 + super().setUp()
19 self.site_2 = Site.objects.create(id=settings.SITE_ID + 1, 17 self.site_2 = Site.objects.create(id=settings.SITE_ID + 1,
20 domain="testserver", name="testserver") 18 domain="testserver", name="testserver")
21 19
1 -from __future__ import absolute_import  
2 -  
3 from django.core import mail 1 from django.core import mail
4 from django.test.utils import override_settings 2 from django.test.utils import override_settings
5 3
1 -from __future__ import absolute_import, unicode_literals  
2 -  
3 from django.conf import settings 1 from django.conf import settings
4 from django.contrib.auth.models import User 2 from django.contrib.auth.models import User
5 3
1 -from __future__ import absolute_import  
2 -  
3 from xml.etree import ElementTree as ET 1 from xml.etree import ElementTree as ET
4 2
5 from django.conf import settings 3 from django.conf import settings
1 -from __future__ import absolute_import  
2 -  
3 from django_comments.models import Comment 1 from django_comments.models import Comment
4 2
5 from . import CommentTestCase 3 from . import CommentTestCase
1 -from __future__ import absolute_import, unicode_literals  
2 -  
3 from django.contrib.auth.models import User, Permission 1 from django.contrib.auth.models import User, Permission
4 from django.contrib.contenttypes.models import ContentType 2 from django.contrib.contenttypes.models import ContentType
5 from django.test.utils import override_settings 3 from django.test.utils import override_settings
@@ -268,7 +266,7 @@ class ApproveViewTests(CommentTestCase): @@ -268,7 +266,7 @@ class ApproveViewTests(CommentTestCase):
268 class AdminActionsTests(CommentTestCase): 266 class AdminActionsTests(CommentTestCase):
269 267
270 def setUp(self): 268 def setUp(self):
271 - super(AdminActionsTests, self).setUp() 269 + super().setUp()
272 270
273 # Make "normaluser" a moderator 271 # Make "normaluser" a moderator
274 u = User.objects.get(username="normaluser") 272 u = User.objects.get(username="normaluser")
1 -from __future__ import absolute_import  
2 -  
3 from django.conf import settings 1 from django.conf import settings
4 from django.contrib.contenttypes.models import ContentType 2 from django.contrib.contenttypes.models import ContentType
5 from django.contrib.sites.models import Site 3 from django.contrib.sites.models import Site
@@ -17,7 +15,7 @@ from . import CommentTestCase @@ -17,7 +15,7 @@ from . import CommentTestCase
17 class CommentTemplateTagTests(CommentTestCase): 15 class CommentTemplateTagTests(CommentTestCase):
18 16
19 def setUp(self): 17 def setUp(self):
20 - super(CommentTemplateTagTests, self).setUp() 18 + super().setUp()
21 self.site_2 = Site.objects.create(id=settings.SITE_ID + 1, 19 self.site_2 = Site.objects.create(id=settings.SITE_ID + 1,
22 domain="testserver", name="testserver") 20 domain="testserver", name="testserver")
23 21
1 -from __future__ import absolute_import  
2 -  
3 from django.conf.urls import url 1 from django.conf.urls import url
4 from django.contrib.contenttypes.views import shortcut 2 from django.contrib.contenttypes.views import shortcut
5 3
1 [tox] 1 [tox]
2 envlist = 2 envlist =
3 - py{27,34,35,36,37}-django111 3 + py{34,35,36,37}-django111
4 py3{4,5,6,7}-django20 4 py3{4,5,6,7}-django20
5 py3{5,6,7}-django21 5 py3{5,6,7}-django21
6 py3{5,6,7}-django22 6 py3{5,6,7}-django22
@@ -9,7 +9,6 @@ envlist = @@ -9,7 +9,6 @@ envlist =
9 9
10 [testenv] 10 [testenv]
11 basepython = 11 basepython =
12 - py27: python2.7  
13 py34: python3.4 12 py34: python3.4
14 py35: python3.5 13 py35: python3.5
15 py36: python3.6 14 py36: python3.6
Please register or login to post a comment