[redland-dev] [Redland Language Bindings 0000403]: destructor for RDF.Query throws an exception

Mantis Bug Tracker mantis-bug-sender at librdf.org
Wed Dec 1 21:35:08 CET 2010


The following issue has been SUBMITTED. 
====================================================================== 
http://bugs.librdf.org/mantis/view.php?id=403 
====================================================================== 
Reported By:                thomasvs
Assigned To:                
====================================================================== 
Project:                    Redland Language Bindings
Issue ID:                   403
Category:                   api
Reproducibility:            always
Severity:                   crash
Priority:                   normal
Status:                     new
Binding Language (java, perl, php, python, ruby, tcl): python 
====================================================================== 
Date Submitted:             2010-12-01 20:35
Last Modified:              2010-12-01 20:35
====================================================================== 
Summary:                    destructor for RDF.Query throws an exception
Description: 
While adapting my python program moap to adapt to changed symantics in
str(Node), one of my invocations triggered the following traceback:
DEBUG [20950]                                  doap              Dec 01 21:24:43
     querying u'\nPREFIX rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX doap:
<http://usefulinc.com/ns/doap#>\nPREFIX foaf:
<http://xmlns.com/foaf/0.1/>\nSELECT ?fileRelease\nWHERE {\n      ?project
rdf:type doap:Project .\n      ?project doap:shortname "moap" .\n      ?project
doap:release ?release .\n      ?release doap:revision "0.2.7" .\n      ?release
doap:file-release ?fileRelease\n}\n' (moap/doap/doap.py:191)
Traceback (most recent call last):
  File "/home/thomas/dev/own/moap/trunk/bin/moap", line 28, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/home/thomas/dev/own/moap/trunk/moap/main.py", line 13, in main
    ret = c.parse(argv)
  File "/home/thomas/dev/own/moap/trunk/moap/extern/command/command.py", line
329, in parse
    return self.subCommands[command].parse(args[1:])
  File "/home/thomas/dev/own/moap/trunk/moap/extern/command/command.py", line
329, in parse
    return self.subCommands[command].parse(args[1:])
  File "/home/thomas/dev/own/moap/trunk/moap/extern/command/command.py", line
300, in parse
    ret = self.do(args)
  File "/home/thomas/dev/own/moap/trunk/moap/command/doap.py", line 419, in do
    project = d.getProject()
  File "/home/thomas/dev/own/moap/trunk/moap/doap/doap.py", line 126, in
getProject
    self._queryReleases(p)
  File "/home/thomas/dev/own/moap/trunk/moap/doap/doap.py", line 170, in
_queryReleases
    self._queryFileReleases(p, v)
  File "/home/thomas/dev/own/moap/trunk/moap/doap/doap.py", line 192, in
_queryFileReleases
    result = self._querier.query(querystring, query_language='sparql')
  File "/home/thomas/dev/own/moap/trunk/moap/doap/common.py", line 43, in query
    q = RDF.Query(querystring, query_language=query_language)
  File "/usr/lib64/python2.7/site-packages/RDF.py", line 1943, in __init__
    self._query = Redland.librdf_new_query(_world._world, query_language, ruri,
querystring, rbase_uri)
TypeError: in method 'librdf_new_query', argument 4 of type 'char const *'
Exception AttributeError: "'Query' object has no attribute '_query'" in <bound
method Query.__del__ of <RDF.Query object at 0x7fd5b16ce410>> ignored


The TypeError is worrying.
__del__ destructors are usually not a good idea; from going through the code, it
seems that the __init__ method triggers an exception before self._query is set,
and then the destructor generates an additional exception.

See
http://www.algorithm.co.il/blogs/index.php/programming/python/python-gotchas-1-__del__-is-not-the-opposite-of-__init__/

So the basic problem here seems to be the query call failing.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-12-01 20:35 thomasvs       New Issue                                    
======================================================================



More information about the redland-dev mailing list