Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mypyc produces module that crashes (segmentation fault) when executed #18992

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

Open
svalentin opened this issue Apr 28, 2025 · 1 comment
Open
Labels

Comments

@svalentin
Copy link
Collaborator

compiled.py:

from typing import Generic, TypeVar

_T = TypeVar("_T")

class Bar(Generic[_T]):
    def __init__(self) -> None:
        self.value: str = 'start'
    def __get__(self, instance: _T, owner: type[_T] | None = None) -> str:
        return self.value
    def __set__(self, instance: _T, value: str) -> None:
        self.value = value

class Foo(object):
    bar: Bar = Bar()

Compiled with python3 -m mypyc compiled.py.

test.py:

import compiled

print("hello")

f = compiled.Foo()
print(f.bar)

f.bar = 'test'
print(f.bar)

And running with:

$ python3 test.py
hello
<compiled.Bar object at 0x7464e7774310>
Segmentation fault

Using current master of mypyc:

$ python3 -m mypyc --version
mypy 1.16.0+dev.7b4f6311e29452cc8d4ddb78331d0047c8b17e93.dirty (compiled: no)

Using Python 3.13.1

If running with python3 directly:

$ python3 test.py
hello
start
test
@svalentin
Copy link
Collaborator Author

Output when using a debug version of python:

$ python3 test.py
hello
<compiled.Bar object at 0x7cc5bb0dfde0>
Traceback (most recent call last):
  File "/home/svalentin/src/mypy-svalentin/test/test.py", line 8, in <module>
    f.bar = 'test'
    ^^^^^
TypeError: compiled.Bar object expected; got str
Segmentation fault

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

1 participant