Commit 32f09fb 1 parent 4497afe commit 32f09fb Copy full SHA for 32f09fb
File tree 3 files changed +5
-5
lines changed
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):
453
453
def p_expression_string (self , p ):
454
454
'object : STRING'
455
455
try :
456
- value = literal_eval ( p [1 ])
456
+ value = p [1 ][ 1 : - 1 ]. encode (). decode ( 'unicode-escape' )
457
457
except Exception :
458
458
raise errors .StringSyntaxError ('invalid string literal' , p [1 ][1 :- 1 ]) from None
459
459
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):
208
208
209
209
def test_builtins_re_groups (self ):
210
210
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 )
212
212
self .assertIsNone (context ._tls .regex_groups )
213
213
words = (
214
214
'' .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):
74
74
75
75
def test_tls_for_regex1 (self ):
76
76
context = engine .Context ()
77
- rule = engine .Rule ('words =~ "(\w+) \w+"' , context = context )
77
+ rule = engine .Rule (r 'words =~ "(\\ w+) \ \w+"' , context = context )
78
78
rule .evaluate ({'words' : 'MainThread Test' })
79
79
self .assertEqual (context ._tls .regex_groups , ('MainThread' ,))
80
80
RuleThread (rule , {'words' : 'AlternateThread Test' }).join ()
@@ -83,11 +83,11 @@ def test_tls_for_regex1(self):
83
83
def test_tls_for_regex2 (self ):
84
84
lock = threading .RLock ()
85
85
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 )
87
87
self .assertTrue (rule .evaluate ({'words' : 'MainThread Test' }))
88
88
lock .release ()
89
89
with lock :
90
90
thread = RuleThread (rule , {'words' : 'AlternateThread Test' })
91
91
self .assertTrue (rule .evaluate ({'words' : 'MainThread Test' }))
92
92
lock .release ()
93
- self .assertFalse (thread .join ())
93
+ self .assertFalse (thread .join ())
You can’t perform that action at this time.
0 commit comments