Loading ...
Sorry, an error occurred while loading the content.

4263[Cheetahtemplate-discuss] [PATCH] Fix test, and correct the error cast in the compiler

Expand Messages
  • R. Tyler Ballance
    Jan 5, 2009
    • 0 Attachment
      Cheetah markup like this:
      #try
      #import cjson
      #except ImportError
      #import simplejson
      #end try

      Will now appropriately generate this code:
      try:
      import cjson
      except ImportError:
      import simplejson

      Instead of what it previously generated:
      import cjson
      import simplejson

      try:
      except ImportError

      Signed-off-by: R. Tyler Ballance <tyler@...>
      ---
      src/Compiler.py | 2 +-
      src/Tests/Template.py | 4 ++--
      2 files changed, 3 insertions(+), 3 deletions(-)

      diff --git a/src/Compiler.py b/src/Compiler.py
      index a2fc7e5..cc1c94e 100644
      --- a/src/Compiler.py
      +++ b/src/Compiler.py
      @@ -1712,7 +1712,7 @@ class ModuleCompiler(SettingsManager, GenUtils):
      return self._importedVarNames

      def addImportedVarNames(self, varNames):
      - self._importedVarNames.extend(varNames)
      + self.addChunk('import %s' % ', '.join(varNames))

      ## methods for adding stuff to the module and class definitions

      diff --git a/src/Tests/Template.py b/src/Tests/Template.py
      index d95b507..c8b6ee8 100644
      --- a/src/Tests/Template.py
      +++ b/src/Tests/Template.py
      @@ -307,8 +307,8 @@ class Preprocessors(TemplateTest):

      class TryExceptImportTest(TemplateTest):
      def test_FailCase(self):
      + ''' Test situation where an inline #import statement will get relocated '''
      source = '''
      -
      #def myFunction()
      Ahoy!
      #try
      @@ -318,8 +318,8 @@ class TryExceptImportTest(TemplateTest):
      #end try
      #end def
      '''
      + # This should raise an IndentationError (if the bug exists)
      klass = Template.compile(source=source)
      - print klass
      t = klass(namespaces={'foo' : 1234})


      --
      1.6.0.2


      ------------------------------------------------------------------------------
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Show all 2 messages in this topic