adriank / ObjectPath

The agile query language for semi-structured data
http://objectpath.org
MIT License
380 stars 93 forks source link

UnboundLocalError: local variable 'ret' referenced before assignment #73

Closed crismotinha closed 2 years ago

crismotinha commented 5 years ago

Hi!

It's my first time using ObjectPath, and I'm getting this error:

Traceback (most recent call last):
  File "script.py", line 19, in <module>
    res = tree.execute('$.issues[@.changelog.histories[@.items[0].toString is "Done"]]')
  File "C:\Users\cmmartins\AppData\Local\Programs\Python\Python37-32\lib\site-packages\objectpath\core\interpreter.py", line 608, in execute
    ret=exe(tree)
  File "C:\Users\cmmartins\AppData\Local\Programs\Python\Python37-32\lib\site-packages\objectpath\core\interpreter.py", line 328, in exe
    nodeList_append(exe((selector[0],exe(selector[1]),exe(selector[2]))))
  File "C:\Users\cmmartins\AppData\Local\Programs\Python\Python37-32\lib\site-packages\objectpath\core\interpreter.py", line 234, in exe
    return ret
UnboundLocalError: local variable 'ret' referenced before assignment

I don't know if my query is wrong (toString is a property, maybe this is the problem?) but the error is not being treated. I saw this issue in another repo (https://github.com/miguelgrinberg/python-socketio/issues/85), maybe this guy solution helps you.

Thank you!

adriank commented 5 years ago

From what I remember ObjectPath has a limitation on how you can use the current operator (@). You can use it only once per query. Run ObjectPath in debug mode and see what it is doing.