[redland-dev] Perl literal pickiness

Dave Beckett dave at dajobe.org
Sat Nov 4 04:57:51 UTC 2006


Kieron Taylor wrote:
> I'm not sure when the change happened, but recently I've been suffering
> from all my old code breaking with the following runtime error:
> 
> TypeError in method 'librdf_new_node_from_typed_literal', argument 2 of
> type 'char const *'
> 
> Invariably I have chased the problem down to cases of unquoted numerical
> values being passed into the method. It seems to me that Redland is
> coercing the data into variable types differently to older versions. I
> am making the calls through the Perl bindings where typing is weak.

That sounds more like a SWIG change, enforcing it wants a string.  Seems
odd since perl doesn't distinguish strings and numerics, they are all
just scalars.

> Is this intended behaviour, and do I need to be much more vigorous in my
> quoting of potentially numerical variables?

I don't know, you'll have to give some more information - versions
of perl, swig, redland and an example in perl of what's failing.

> In a related problem that gives the same error, I have found the Perl
> bindings unwilling to operate if I declare a null base uri for the
> parser/serialiser etc. What would be the correct way to declare a blank
> base uri?

All serializers require a base URI right now, you can't have a NULL
one.  That's something it might be possible to change in future.

For parsers, you should be able to just pass in undef however it looks like
not all the calls may be checking and are just using $base_uri->{URI} so in
those cases you could pass in an assoc array reference {URI => undef} like:

  $base_uri=(URI => undef);
  $result=$parser->some_method(args, \$base_uri);


Dave


More information about the redland-dev mailing list