gjhiggins/rdflib — Issue #79: TypeError in SPARQLEvaluate when using FILTER regex( '', '', 'i')
Author: gjhiggins
Created: 2011-10-19 01:14:12+00:00
State: open

Originally filed by alieng...@gmail.com on 2009-08-10T06:22:05

What steps will reproduce the problem?
1. python test/test_sparql/sparl_regex.py

I was trying to follow along with one of the examples in Programming the
Semantic Web, and got an exception in sparql queries that had a FILTER
regex() statement.

What is the expected output? What do you see instead?
Using your already existing testing code. I get this exception:
======================================================================
ERROR: testRegex (__main__.TestRegex)
----------------------------------------------------------------------
Traceback (most recent call last):
File "sparql_regex.py", line 31, in testRegex
results = graph.query(test_query)
File "/Users/diane/src/python/rdflib/devel/rdflib/graph.py", line 804, in
query
dataSetBase, extensionFunctions))
File
"/Users/diane/src/python/rdflib/devel/rdflib/sparql/bison/Processor.py",
line 54, in query
extensionFunctions=extensionFunctions)
File "/Users/diane/src/python/rdflib/devel/rdflib/sparql/Algebra.py",
line 317, in TopEvaluate
None)
File "/Users/diane/src/python/rdflib/devel/rdflib/sparql/Algebra.py",
line 166, in ReduceToAlgebra
prolog))
File
"/Users/diane/src/python/rdflib/devel/rdflib/sparql/bison/SPARQLEvaluate.py",
line 358, in createSPARQLPConstraint
constraint=const)
File
"/Users/diane/src/python/rdflib/devel/rdflib/sparql/bison/SPARQLEvaluate.py",
line 235, in mapToOperator
expr.arg3 and ',"'+expr.arg3 + '"' or '',
TypeError: cannot concatenate 'str' and
'ParsedConditionalAndExpressionList' objects

What version of the product are you using? On what operating system?
I'm using svn revno 1691, on os x 10.5 with the standard python 2.5 and
easy_installed dependencies.

Please provide any additional information below.

Changing expr.arg3 to expr.arg3.reduce() in mapToOperator in
SPARQLEvaluate.py seems to have fixed the crash, and also seems to produce
a believable argument.