Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #866 RunTimeError when generator is nested in more than 1 level of function definition #867

merged 3 commits into from Jul 14, 2018


None yet
2 participants
Copy link

commented Jul 12, 2018

On closer inspection, the reason for the RuntimeError in #866 was due to incorrect class path name.

Considering the code below (

def wrapped():
    def func():
        def gen():
            yield 'Hello World'



The path to gen would be python.Test.func$gen, as indicated in compilation output:

Compiling ...
Writing .\python\Test.class ...
Writing .\python\Test\func.class ...
Writing .\python\Test\func$gen.class ...

However, during runtime, the path to gen becomes python.Test.func.gen instead of python.Test.func$gen, causing java.lang.ClassNotFoundException which is wrapped in RuntimeError.

The root cause is on line 1118 of, when declaring classpath of generator method, self.klass.class_name returns python.Test.func.gen. To fix this, I replaced it with self.class_descriptor.replace('/', '.') to get python.Test.func$gen

Copy link

left a comment

Patch makes sense, but needs a test

BPYap added some commits Jul 13, 2018


This comment has been minimized.

Copy link
Contributor Author

commented Jul 13, 2018

@freakboy3742 Done 😄

@freakboy3742 freakboy3742 merged commit 7e9cdf2 into beeware:master Jul 14, 2018

5 checks passed

beekeeper:0/beefore:javacheckstyle Java lint checks passed.
beekeeper:0/beefore:pycodestyle Python lint checks passed.
beekeeper:1/smoke-test Smoke build (Python 3.4) passed.
beekeeper:2/full-test:py3.5 Python 3.5 tests passed.
beekeeper:2/full-test:py3.6 Python 3.6 tests passed.

@BPYap BPYap deleted the BPYap:fix-nested-generator branch Jul 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.