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

Bug: NamedTuple doesn't work after cythonization #2649

Closed
vvegorova opened this Issue Oct 9, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@vvegorova

vvegorova commented Oct 9, 2018

I have some module defining a NamedTuple:

nmt.py:

from typing import NamedTuple

class Employee(NamedTuple):
    name: str
    id: int

and a simple setup.py:

from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules=cythonize("nmt.py"))

I build the module like this

python setup.py build_ext --inplace

The result class Employee can't be properly instantiated:

>>> from nmt import Employee

>>> Employee("a", 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __new__() takes 1 positional argument but 3 were given

>>> Employee("a")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __new__() takes 1 positional argument but 2 were given

>>> Employee()
Employee()

@scoder scoder added the R: duplicate label Oct 14, 2018

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Oct 14, 2018

Contributor

Duplicate of #2552.

Contributor

scoder commented Oct 14, 2018

Duplicate of #2552.

@scoder scoder closed this Oct 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment