Fix for #1873 avoid AttributeError raised ... · Pull Request #2013 · RDFLib/rdflib (original) (raw)

Just a note for posterity's sake, this patch works because it prevents an AttributeError from occuring, and instead a SPARQLError occurs later, specifically here:

return Literal("".join(string(x) for x in expr.arg), datatype=dt, lang=lang)

The SPARQLError that occurs later is correctly handled as per the standard here:

def evalExtend(
ctx: QueryContext, extend: CompValue
) -> Generator[FrozenBindings, None, None]:
# TODO: Deal with dict returned from evalPart from GROUP BY
for c in evalPart(ctx, extend.p):
try:
e = _eval(extend.expr, c.forget(ctx, _except=extend._vars))
if isinstance(e, SPARQLError):
raise e
yield c.merge({extend.var: e})
except SPARQLError:
yield c