libpython-clj
libpython-clj copied to clipboard
builtins/eval throws 'frame does not exist'
(require-python '[builtins :as bt])
(bt/eval "1")
;Execution error at libpython-clj2.python.ffi/check-error-throw (ffi.clj:708) .
; SystemError: frame does not exist
while this works
(require-python '[builtins :as bt])
(bt/eval "1" {})
while in python both work:
>>> eval('1+1')
2
>>> eval('1+1',{})
2
If you try from embedded mode it should work. I can't remember the trick but you need to create a base frame by running py/run-simple-string otherwise.
Footnotes:
- if you do
(import-python)you get access to thePythonnamespace which will Let you dopython/eval.
@behrica
(import-python)
(python/eval "1" (:globals (py/run-simple-string ""))) ;;=> 1
Black magic.
Actually...
(python/eval "1" (python/dict)) ;;=> 1
also works :thinking:
You know, I gotta say, sometimes libpython-clj confuses me.
(python/eval "eval('eval(\"1\")', {\"eval\": eval})" {"eval" python/eval}) ;;=> 1