File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed
Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -453,7 +453,7 @@ def p_expression_set(self, p):
453453 def p_expression_string (self , p ):
454454 'object : STRING'
455455 try :
456- value = literal_eval ( p [1 ])
456+ value = p [1 ][ 1 : - 1 ]. encode (). decode ( 'unicode-escape' )
457457 except Exception :
458458 raise errors .StringSyntaxError ('invalid string literal' , p [1 ][1 :- 1 ]) from None
459459 p [0 ] = _DeferredAstNode (ast .StringExpression , args = (self .context , value ))
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ def test_builtins_function_range(self):
208208
209209 def test_builtins_re_groups (self ):
210210 context = engine .Context ()
211- rule = engine .Rule ('words =~ "(\\ w+) (\\ w+) (\\ w+)" and $re_groups[0] == word0' , context = context )
211+ rule = engine .Rule (r 'words =~ "(\\w+) (\\w+) (\\w+)" and $re_groups[0] == word0' , context = context )
212212 self .assertIsNone (context ._tls .regex_groups )
213213 words = (
214214 '' .join (random .choice (string .ascii_letters ) for _ in range (random .randint (4 , 12 ))),
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ def test_tls_for_comprehension(self):
7474
7575 def test_tls_for_regex1 (self ):
7676 context = engine .Context ()
77- rule = engine .Rule ('words =~ "(\w+) \w+"' , context = context )
77+ rule = engine .Rule (r 'words =~ "(\\ w+) \ \w+"' , context = context )
7878 rule .evaluate ({'words' : 'MainThread Test' })
7979 self .assertEqual (context ._tls .regex_groups , ('MainThread' ,))
8080 RuleThread (rule , {'words' : 'AlternateThread Test' }).join ()
@@ -83,11 +83,11 @@ def test_tls_for_regex1(self):
8383 def test_tls_for_regex2 (self ):
8484 lock = threading .RLock ()
8585 context = engine .Context (resolver = functools .partial (testing_resolver , lock ))
86- rule = engine .Rule ('words =~ "(\w+) \w+" and lock and $re_groups[0] == "MainThread"' , context = context )
86+ rule = engine .Rule (r 'words =~ "(\\ w+) \ \w+" and lock and $re_groups[0] == "MainThread"' , context = context )
8787 self .assertTrue (rule .evaluate ({'words' : 'MainThread Test' }))
8888 lock .release ()
8989 with lock :
9090 thread = RuleThread (rule , {'words' : 'AlternateThread Test' })
9191 self .assertTrue (rule .evaluate ({'words' : 'MainThread Test' }))
9292 lock .release ()
93- self .assertFalse (thread .join ())
93+ self .assertFalse (thread .join ())
You can’t perform that action at this time.
0 commit comments