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

Cython cant generate valid C file when asyn generators is used #2075

Closed
jfrancisco-neto opened this issue Jan 16, 2018 · 1 comment
Closed
Labels
Milestone

Comments

@jfrancisco-neto
Copy link

I can reproduce the problem using this simple code in the master branch with last commit 'f9d1114' :

from asyncio import sleep

class App:

    async def a_generator(self):
        for i in range(10):
            await sleep(1)
            yield 

Error message:

src/lib/app.c(1470): error C2065: '__Pyx_PyExc_StopAsyncIteration': identificador não declarado
src/lib/app.c(1470): warning C4047: 'função': 'PyObject *' difere em níveis de indireção de 'int'
src/lib/app.c(1470): warning C4024: 'PyErr_SetNone': tipos diferentes para parâmetro formal e real 1
src/lib/app.c(2784): error C2065: '__Pyx_PyExc_StopAsyncIteration': identificador não declarado
src/lib/app.c(2784): warning C4047: 'função': 'PyObject *' difere em níveis de indireção de 'int'
src/lib/app.c(2784): warning C4024: 'PyErr_SetNone': tipos diferentes para parâmetro formal e real 1
src/lib/app.c(2851): error C2065: '__Pyx_PyExc_StopAsyncIteration': identificador não declarado
src/lib/app.c(2851): warning C4047: '=': 'PyObject *' difere em níveis de indireção de 'int'
src/lib/app.c(5768): error C2065: '__Pyx_PyExc_StopAsyncIteration': identificador não declarado
src/lib/app.c(5768): warning C4047: 'função': 'PyObject *' difere em níveis de indireção de 'int'
src/lib/app.c(5768): warning C4024: 'PyErr_SetNone': tipos diferentes para parâmetro formal e real 1
src/lib/app.c(5770): error C2065: '__Pyx_PyExc_StopAsyncIteration': identificador não declarado
src/lib/app.c(5770): warning C4047: 'função': 'PyObject *' difere em níveis de indireção de 'int'
src/lib/app.c(5770): warning C4024: '__Pyx_PyErr_GivenExceptionMatches2': tipos diferentes para parâmetro formal e real 2
src/lib/app.c(5776): warning C4013: '__Pyx_ReturnWithStopIteration' indefinido; assumindo extern retornando int
src/lib/app.c(6121): error C2065: '__Pyx_PyExc_StopAsyncIteration': identificador não declarado
src/lib/app.c(6121): warning C4047: 'função': 'PyObject *' difere em níveis de indireção de 'int'
src/lib/app.c(6121): warning C4024: 'PyErr_ExceptionMatches': tipos diferentes para parâmetro formal e real 1
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.12.25827\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

App.c: https://gist.github.com/CronosTs/3f5de2ae7844a37951e2ca2de5ce9f4a

Evnriroiment:

Python 3.6.4
Cython 0.28a0
pipenv 9.0.1
Windows 10 64bit

Commands to reproduce

pipenv shell
python setup.py build_ext --inplace

Setup py used:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Compiler import Options


def create_extensions(*extensions):
    for ext in extensions:
        yield Extension(ext, [('src.' + ext).replace('.', '/') + '.py'])

extensions = create_extensions(
  'lib.app'  
)
    
setup(
    name = 'app'
    , ext_modules = cythonize(list(extensions))
)

Project Structure

Project
|-- setup.py
|-- src /
       | -- lib /
              | -- app.py
              | -- __init__.py

BTW, i'm Brazilian, so the message errors are in brazilian portuguese (automatically translated by the visual studio)

@scoder
Copy link
Contributor

scoder commented Jan 16, 2018

Thanks for the report.

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

No branches or pull requests

2 participants