-
-
Notifications
You must be signed in to change notification settings - Fork 3k
mypyc 1.16 regression: x86_64-cpython-3{9,10,11,12,13} error: ‘FOO_finalize’ undeclared here (not in a function); did you mean ‘FOO_init’? #19175
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
Comments
Thanks for reporting the issue! The next step would be to find the root cause by bisecting mypy and mypyc commits. |
This PR looks related: Now we need a self-contained reproducer, which we can use to check if the above PR is the root cause, or to bisect across all commits otherwise. |
Thank you @JukkaL ; I have to finish other work right now, so I can't dig in further today. Here's the is Python source code for the class related to the error: https://github.com/common-workflow-language/schema_salad/blob/0f8e2e888b38bff4e07a91807da430ca2a635376/schema_salad/ref_resolver.py#L96-L119 |
I nerdsniped myself, here is a minimal reproducer
from typing import Any, Callable, Union
from ruamel.yaml.comments import CommentedMap, CommentedSeq
class NormDict(dict[str, Union[CommentedMap, CommentedSeq, str, None]]):
"""A Dict where all keys are normalized using the provided function."""
def __init__(self, normalize: Callable[[str], str] = str) -> None:
super().__init__()
self.normalize = normalize
def __eq__(self, other: Any) -> bool:
return super().__eq__(other)
def __getitem__(self, key: Any) -> Any:
return super().__getitem__(self.normalize(key))
def __setitem__(self, key: Any, value: Any) -> Any:
return super().__setitem__(self.normalize(key), value)
def __delitem__(self, key: Any) -> Any:
return super().__delitem__(self.normalize(key))
def __contains__(self, key: Any) -> bool:
return super().__contains__(self.normalize(key))
def __del__(self) -> None:
del self.normalize $ pip install mypy==1.15.0
[…]
$ mypyc ref_resolver.py
running build_ext
building 'ref_resolver' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/build
x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -fwrapv -O2 -fPIC -I/home/michael/ss2/env3.11/lib/python3.11/site-packages/mypyc/lib-rt -I/home/michael/ss2/env3.11/include -I/usr/include/python3.11 -c build/__native.c -o build/temp.linux-x86_64-cpython-311/build/__native.o -O3 -g1 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cpp
creating build/lib.linux-x86_64-cpython-311
x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-x86_64-cpython-311/build/__native.o -L/usr/lib/x86_64-linux-gnu -o build/lib.linux-x86_64-cpython-311/ref_resolver.cpython-311-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-cpython-311/ref_resolver.cpython-311-x86_64-linux-gnu.so ->
$ rm -Rf ref_resolver.*.so .mypy_cache/ build/
$ pip install mypy==1.16.0
[…]
$ mypyc ref_resolver.py
running build_ext
building 'ref_resolver' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/build
x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -g -fwrapv -O2 -fPIC -I/home/michael/ss2/env3.11/lib/python3.11/site-packages/mypyc/lib-rt -I/home/michael/ss2/env3.11/include -I/usr/include/python3.11 -c build/__native.c -o build/temp.linux-x86_64-cpython-311/build/__native.o -O3 -g1 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cpp
build/__native.c:162:32: error: ‘NormDict_finalize’ undeclared here (not in a function); did you mean ‘NormDict_init’?
162 | .tp_finalize = (destructor)NormDict_finalize,
| ^~~~~~~~~~~~~~~~~
| NormDict_init
cc1: note: unrecognized command-line option ‘-Wno-ignored-optimization-argument’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-unused-command-line-argument’ may have been intended to silence earlier diagnostics
error: command '/usr/lib/ccache/x86_64-linux-gnu-gcc' failed with exit code 1
$ x86_64-linux-gnu-gcc --version
x86_64-linux-gnu-gcc (Debian 12.2.0-14+deb12u1) 12.2.0 |
You nerd-sniped me further because surely that's too complex for a minimal reproducer. This still reproduces it: class NormDict(dict):
def __del__(self) -> None:
pass
|
I did a #!/bin/bash
python -m pip install -e .
rm -Rf build .mypy_cache mypyc_crash.*.so
python -m mypyc mypyc_crash.py Which found 8104d01 from #18519 matching the previous suggestion by @JelleZijlstra . @advait-dixit can you take a look at this? |
Yes, I can take a look at this and report back on Monday. |
Uh oh!
There was an error while loading. Please reload this page.
Crash Report
compiling Python modules using mypyc failed with a gcc error, where it did not using mypy 1.15
Python 3.9: https://github.com/common-workflow-language/schema_salad/actions/runs/15347015751/job/43185437280?pr=927#step:6:450
Python 3.10: https://github.com/common-workflow-language/schema_salad/actions/runs/15347015751/job/43185437282?pr=927#step:6:439
Python 3.11: https://github.com/common-workflow-language/schema_salad/actions/runs/15347015751/job/43185437303?pr=927#step:6:433
Python 3.12: https://github.com/common-workflow-language/schema_salad/actions/runs/15347015751/job/43185437295?pr=927#step:6:425
Python 3.13: https://github.com/common-workflow-language/schema_salad/actions/runs/15347015751/job/43185437315?pr=927#step:6:425
Traceback
To Reproduce
tox -e py39-mypy
(orpy310-mypy
, up topy313-mypy
); or make a virtualenv and activate it, andmake dev mypyc
Your Environment
MYPYPATH=mypy-stubs SCHEMA_SALAD_USE_MYPYC=1 pip install --verbose -e .
mypy.ini
(and other config files): https://github.com/common-workflow-language/schema_salad/blob/dependabot/pip/mypy-mypyc--1.16.0/mypy.iniThe text was updated successfully, but these errors were encountered: