~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to pybb/util.py

  • Committer: kaputtnik
  • Date: 2019-06-14 18:40:56 UTC
  • mfrom: (532.1.31 widelands)
  • Revision ID: kaputtnik-20190614184056-l0ha8pm5zais9mxk
Adapted code for use with python 3.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
from django.http import HttpResponse
11
11
from django.utils.functional import Promise
12
12
from django.utils.translation import check_for_language
13
 
from django.utils.encoding import force_unicode
 
13
from django.utils.encoding import force_text
14
14
from django import forms
15
15
from django.core.paginator import Paginator, EmptyPage, InvalidPage
16
16
from django.conf import settings
59
59
        if request.method == 'POST':
60
60
            try:
61
61
                response = func(request, *args, **kwargs)
62
 
            except Exception, ex:
 
62
            except Exception as ex:
63
63
                response = {'error': traceback.format_exc()}
64
64
        else:
65
65
            response = {'error': {'type': 403,
76
76
 
77
77
    def default(self, o):
78
78
        if isinstance(o, Promise):
79
 
            return force_unicode(o)
 
79
            return force_text(o)
80
80
        else:
81
81
            return super(LazyJSONEncoder, self).default(o)
82
82
 
144
144
        # Apply the new content
145
145
        found_string.parent.contents = new_content
146
146
 
147
 
    return unicode(soup)
 
147
    return str(soup)
148
148
 
149
149
 
150
150
def quote_text(text, user, markup):