Skip to content
Browse files
[processing] Don't throw an exception if an expression cannot
be prepared

There's cases where this happens without reflecting an invalid
expression. So we can try to prepare, but not abort if the
preparation fails.

Fixes #18103
  • Loading branch information
nyalldawson committed Feb 15, 2018
1 parent e0b1d37 commit a811036
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
@@ -123,9 +123,7 @@ def processAlgorithm(self, parameters, context, feedback):
if layer is not None:

if not expression.prepare(exp_context):
raise QgsProcessingException('Evaluation error: {0}').format(expression.parserErrorString()))

features = source.getFeatures()
total = 100.0 / source.featureCount() if source.featureCount() else 0
@@ -116,9 +116,7 @@ def processAlgorithm(self, parameters, context, feedback):
raise QgsProcessingException(expression.parserErrorString())

expressionContext = self.createExpressionContext(parameters, context, source)
if not expression.prepare(expressionContext):
raise QgsProcessingException('Evaluation error: {0}').format(expression.evalErrorString()))

fields = QgsFields()
fields.append(QgsField('id', QVariant.Int, '', 10, 0))

0 comments on commit a811036

Please sign in to comment.