Diagnostic Handler not working in API Bindings

Bug #867112 reported by Rodolfo Ochoa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
High
Rodolfo Ochoa

Bug Description

When I run this code in python the diagnostic handler method is never called.

class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
  def error(self, *args):
    print "Error args: ", args

def test(zorba, diagnosticHandler):
  try:
    xquery = zorba.compileQuery("1 div 0", diagnosticHandler)
    print xquery.execute()
  except Exception, e:
    print "Cought error: ", e
  return

store = zorba_api.InMemoryStore_getInstance()
zorba = zorba_api.Zorba_getInstance(store)
diagnosticHandler = MyDiagnosticHandler()

print "Running: Compile query string using Diagnostic Handler"
test(zorba, diagnosticHandler)
print "Success"

zorba.shutdown()
zorba_api.InMemoryStore_shutdown(store)

Related branches

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

Paul, could you please look into this?

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Since I know nothing about Python, please specify exactly how to reproduce this bug. I assume copy/paste the above code into something like a test.py file, but what do you do after that? How do you tell python about Zorba? How do you run the test?

Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) wrote :

You need to setup the API Binding for Python... install SWIG, Python libs and rebuild, CMAKE should be able to detect both... then after rebuild, you should have the python binding and you'll be able to execute this example.

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Execute the example *how*? What do I type? Again, I know nothing about python.

Also, when you add a note, you need to assign the bug back to me so I see the note. I waited all morning for you to give the note that you did. I only discovered it by manually checking the bug.

Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) wrote :

call python with the script filename like:
>python example.py

Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) wrote :

you can also verify with CTest
>ctest -V -R python

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

The file test.py was added: Test file.

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Since sourceforge and the browser don't maintain whitespace for code and since Python is particular about whitespace, I've attached the code I'm using. Please review. If it is NOT correct in terms of indentation (or anything else), please edit it and attach a NEW file as test2.py.

When I run this, I get:
Fatal Python error: PyThreadState_Get: no current thread

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

Marked with Resolution = None at Dana's request.

Changed in zorba:
status: New → In Progress
Changed in zorba:
milestone: none → 2.5
Changed in zorba:
status: In Progress → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.