[Checkins] SVN: zope.tales/trunk/src/zope/tales/ Forward-port fix for lp:1002242 from the 3.5 branch.

Tres Seaver cvs-admin at zope.org
Wed May 23 15:54:16 UTC 2012


Log message for revision 126478:
  Forward-port fix for lp:1002242 from the 3.5 branch.

Changed:
  U   zope.tales/trunk/src/zope/tales/expressions.py
  U   zope.tales/trunk/src/zope/tales/tests/test_expressions.py

-=-
Modified: zope.tales/trunk/src/zope/tales/expressions.py
===================================================================
--- zope.tales/trunk/src/zope/tales/expressions.py	2012-05-23 15:52:30 UTC (rev 126477)
+++ zope.tales/trunk/src/zope/tales/expressions.py	2012-05-23 15:54:12 UTC (rev 126478)
@@ -222,7 +222,9 @@
 
 
 
-_interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE})
+_interp = re.compile(
+        r'\$(%(n)s)|\${(%(n)s(?:/[^}|]*)*(?:\|%(n)s(?:/[^}|]*)*)*)}'
+            % {'n': NAME_RE})
 
 @implementer(ITALESExpression)
 class StringExpr(object):

Modified: zope.tales/trunk/src/zope/tales/tests/test_expressions.py
===================================================================
--- zope.tales/trunk/src/zope/tales/tests/test_expressions.py	2012-05-23 15:52:30 UTC (rev 126477)
+++ zope.tales/trunk/src/zope/tales/tests/test_expressions.py	2012-05-23 15:54:12 UTC (rev 126478)
@@ -134,11 +134,24 @@
         context=self.context
         self.assertEqual(expr(context), 'A2')
 
+    def testStringSub_w_python(self):
+        CompilerError = self.engine.getCompilerError()
+        self.assertRaises(CompilerError,
+                          self.engine.compile,
+                                'string:${python:1}')
+
     def testStringSubComplex(self):
         expr = self.engine.compile('string:a ${x/y} b ${y/z} c')
         context=self.context
         self.assertEqual(expr(context), 'a yikes b 3 c')
-    
+
+    def testStringSubComplex_w_miss_and_python(self):
+        # See https://bugs.launchpad.net/zope.tales/+bug/1002242
+        CompilerError = self.engine.getCompilerError()
+        self.assertRaises(CompilerError,
+                          self.engine.compile,
+                            'string:${nothig/nothing|python:1}')
+ 
     def testString8Bits(self):
         # Simple eight bit string interpolation should just work. 
         expr = self.engine.compile('string:a ${eightBits}')



More information about the checkins mailing list