Projet

Général

Profil

0001-misc-adapt-skeletontemplate-tag-for-3.2-64298.patch

Frédéric Péters, 18 avril 2022 15:35

Télécharger (1,79 ko)

Voir les différences:

Subject: [PATCH] misc: adapt skeletontemplate tag for 3.2 (#64298)

This follows this django change:

commit 04ac9b45a34440fa447feb6ae934687aacbfc5f4
Author: Alex Gaynor <alex.gaynor@gmail.com>
Date:   Tue Oct 8 22:25:20 2019 -0400

    Improved performance of django.template.base.Parser.

    pop(0), which is used to fetch each token, is O(n) in the length of the
    list. By reversing the list and operating off the end, we can perform
    next_token(), prepend_token(), and delete_first_token() in constant
    time.
 combo/public/templatetags/combo.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
combo/public/templatetags/combo.py
23 23
from decimal import DivisionByZero as DecimalDivisionByZero
24 24
from decimal import InvalidOperation as DecimalInvalidOperation
25 25

  
26
import django
26 27
from django import template
27 28
from django.core import signing
28 29
from django.core.exceptions import PermissionDenied
......
171 172
        raise template.TemplateSyntaxError("%r tag requires exactly one argument" % token.contents.split()[0])
172 173

  
173 174
    tokens_copy = parser.tokens[:]
175
    if django.VERSION < (3,):
176
        tokens_copy.reverse()
174 177
    text = []
175 178
    while True:
176
        token = tokens_copy.pop(0)
179
        token = tokens_copy.pop()
177 180
        if token.contents == 'end_skeleton_extra_placeholder':
178 181
            break
179 182
        if token.token_type == TOKEN_VAR:
180
-