Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Commit

Permalink
Merge pull request #867 from BPYap/fix-nested-generator
Browse files Browse the repository at this point in the history
Fixed #866 RunTimeError when generator is nested in more than 1 level of function definition
  • Loading branch information
freakboy3742 committed Jul 14, 2018
2 parents df96c08 + cf11940 commit 7e9cdf2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions tests/structures/test_function.py
Expand Up @@ -256,6 +256,20 @@ def nested_func():
func2()
""")

def test_define_nested_generator(self):
self.assertCodeExecution("""
def wrapper():
def func():
def gen():
yield 'Hello World'
print(next(gen()))
func()
wrapper()
""")

def test_noarg_unexpected_extra_arg(self):
self.assertCodeExecution("""
def myfunc():
Expand Down
2 changes: 1 addition & 1 deletion voc/python/methods.py
Expand Up @@ -1119,7 +1119,7 @@ def transpile_wrapper(self):
JavaOpcodes.LDC_W(self.generator),

# p2: The actual generator method
java.Class.forName(self.klass.class_name),
java.Class.forName(self.class_descriptor.replace('/', '.')),

JavaOpcodes.LDC_W(self.method_name + "$generator"),
java.Array(1, 'java/lang/Class'),
Expand Down

0 comments on commit 7e9cdf2

Please sign in to comment.