summaryrefslogtreecommitdiff
path: root/net-analyzer/graphite-web/files/graphite-web-1.1.8-pyparsing3.patch
blob: 6a1c44ff010966e5c536cb56da253e1b8916c1b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Modified to apply on 1.1.8 release

From 5de8405307ded14930b3381380e9f91e583172a9 Mon Sep 17 00:00:00 2001
From: parrotpock <51694161+parrotpock@users.noreply.github.com>
Date: Mon, 15 Nov 2021 17:39:23 +0100
Subject: [PATCH] Fix pyparsing > 3.0 compatibility issue. (#2727)

* Fix bool() issue in recursion termination check.

The behaviour of ParsedResults seems to have changed in the way that
the usage of pop() along with the bool() check on the object interact
wrt checking if there are further elements in the parsed structure to
consume. In version > 3.0 bool() checks whether either the internal
_toklist or _tokdict members contain items left to consume and returns
True if either do, whereas pop with no arguments will only consume from
the underlying list. That means that we would get a True in the if
condition in this code, whereas a subsequent call to pop() would throw
an exception. Calling asList() forces the use of the list representation
in the bool check here and so fixes this issue.

* Fix pyparsing backwards compatibility issue.

* Remove upper-bound on pin.

* Add pyparsing3 test target for versions >= 3.0.6

* Remove try/except, use dictionary key index syntax

Co-authored-by: Ubuntu <ubuntu@ip-172-31-7-19.eu-west-1.compute.internal>
---
 webapp/graphite/render/evaluator.py      | 2 +-
 webapp/graphite/render/grammar_unsafe.py | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/webapp/graphite/render/evaluator.py b/webapp/graphite/render/evaluator.py
index 748626ed0c..12179dcc44 100644
--- a/webapp/graphite/render/evaluator.py
+++ b/webapp/graphite/render/evaluator.py
@@ -58,7 +58,7 @@ def evaluateTokens(requestContext, tokens, replacements=None, pipedArg=None):
     return evaluateTokens(requestContext, tokens.template, arglist)
 
   if tokens.expression:
-    if tokens.expression.pipedCalls:
+    if tokens.expression.pipedCalls.asList():
       # when the expression has piped calls, we pop the right-most call and pass the remaining
       # expression into it via pipedArg, to get the same result as a nested call
       rightMost = tokens.expression.pipedCalls.pop()
diff --git a/webapp/graphite/render/grammar_unsafe.py b/webapp/graphite/render/grammar_unsafe.py
index f25b5eff8f..2481176b53 100644
--- a/webapp/graphite/render/grammar_unsafe.py
+++ b/webapp/graphite/render/grammar_unsafe.py
@@ -80,7 +80,7 @@
 
 
 def setRaw(s, loc, toks):
-    toks[0].raw = s[toks[0].start:toks[0].end]
+    toks[0]['raw'] = s[toks[0].start:toks[0].end]
 
 
 call = Group(