Skip to content

Commit

Permalink
Add test to reproduce scope bug
Browse files Browse the repository at this point in the history
Functions defined in exec should remain visible to subsequent code.
  • Loading branch information
bendudson committed Nov 11, 2020
1 parent 7b965b5 commit fce70be
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/tests.lisp
Expand Up @@ -738,3 +738,21 @@ class Foo():
(assert-equality #'= #C(0.5 1.0)
(py4cl:python-eval #C(1 2) "*" 1/2)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Scope in python exec

(deftest python-exec-scope (pytests)
;; Local functions are retained in scope
;; This changed in python 3.x see e.g. https://stackoverflow.com/a/24734880
(assert-equalp "10
"
(with-output-to-string (*standard-output*)
(py4cl:python-exec "
def foo():
return 5
def bar():
return foo() + foo()
print(bar())"))))

0 comments on commit fce70be

Please sign in to comment.