From b7e90ea07890392b7e31ae5079a539b474b16d81 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 17 Apr 2014 05:49:47 +0300 Subject: objgenerator: Generator must execute in its defining lexical context. I.e. with its own globals. So, just as for functions, we need to switch globals when resuming a generator. --- tests/basics/gen_context.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/basics/gen_context.py (limited to 'tests/basics/gen_context.py') diff --git a/tests/basics/gen_context.py b/tests/basics/gen_context.py new file mode 100644 index 0000000000..02f1531467 --- /dev/null +++ b/tests/basics/gen_context.py @@ -0,0 +1,9 @@ +import gen_context2 + +GLOBAL = "GLOBAL" + +def gen(): + print(GLOBAL) + yield 1 + +gen_context2.call(gen()) -- cgit v1.2.3