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

Updates name template for compatibility with Cython #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

george-kuanli-peng
Copy link

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly

  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])

  • Use Preview tab to see how your pull request will actually look like

  • Searched for similar pull requests

  • Followed PEP8 coding style

  • Tested with proper test samples

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New feature

Description of your pull request and other information

The current generated code cannot be compiled by Cython with errors like this:

[1/3] Cythonizing XXX.py

Error compiling Cython file:
------------------------------------------------------------
...
        if False:
            ci = NotImplemented

        def _walrus_wrapper_ci_54f2f2c3aa5e4a6488fc2b75e012a2b0(expr):
            """Wrapper function for assignment expression."""
            nonlocal ci
            ^
------------------------------------------------------------

XXX.py:125:12: no binding for nonlocal 'ci' found

This PR generates the following code, which introduces some runtime cost but works with Cython:

        if 'ci' not in dir():
            ci = NotImplemented

        def _walrus_wrapper_ci_54f2f2c3aa5e4a6488fc2b75e012a2b0(expr):
            """Wrapper function for assignment expression."""
            nonlocal ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant