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

[BUG] Cannot be executed without any error message. #6166

Open
roydad opened this issue Apr 28, 2024 · 8 comments · May be fixed by #6171
Open

[BUG] Cannot be executed without any error message. #6166

roydad opened this issue Apr 28, 2024 · 8 comments · May be fixed by #6171

Comments

@roydad
Copy link

roydad commented Apr 28, 2024

Describe the bug

Some line cannot be executed without any error message

Code to reproduce the behaviour:

s = 3
print("yes++++++++++")
print(str(s) * 2)  # After this line is compiled to pyd, it cannot be executed without any error message.
print("yes----------")

Expected behaviour

image

OS

windows 11

Python version

3.11.5 amd64

Cython version

3.0.10

Additional context

msvc v140 or mingw64

when cython <= 3.0.a11 it work fine.

@roydad roydad changed the title [BUG] [BUG] Cannot be executed without any error message. Apr 28, 2024
@da-woods
Copy link
Contributor

It works correctly for me (on Linux)

@roydad
Copy link
Author

roydad commented Apr 29, 2024

It works correctly for me (on Linux)
@da-woods
This issue is only on Windows OS, and 3.0.a11 does not have this problem,I have verified that the same issue exists on other windows PC.

@da-woods
Copy link
Contributor

It works correctly for me on Windows with MSVC.

@da-woods
Copy link
Contributor

I'm afraid I can't reproduce it, so won't be able to do much. You might get some information from the faulthandler module (import faulthandler; faulthandler.enable()).

Otherwise it'd be a case of trying to catch the error in a C++ debugger. On Windows that'd be a case of starting Python, attaching the Python to the debugger from "debug -> attach to process" on the Visual Studio UI (not VS Code!), and the importing the module in Python.

@da-woods
Copy link
Contributor

Alternatively you might be doing something odd in the buildpyd.py script. I'm testing just using cythonize -if hello.py where cythonize is a small tool that comes with Cython itself.

@roydad
Copy link
Author

roydad commented Apr 29, 2024

Alternatively you might be doing something odd in the buildpyd.py script. I'm testing just using cythonize -if hello.py where cythonize is a small tool that comes with Cython itself.

@da-woods You are right, the option should be language_level="3str" , but I wrote it as language_level=3
Thanks, the problem is solved.

@roydad roydad closed this as completed Apr 29, 2024
@da-woods
Copy link
Contributor

I'm reopening because I can reproduce it with language_level=3. There's definitely a bug but there wasn't enough information initially.

@da-woods da-woods reopened this Apr 29, 2024
@da-woods
Copy link
Contributor

In the master branch this fixed by 6fd204e although I don't think that can be backported.

da-woods added a commit to da-woods/cython that referenced this issue Apr 29, 2024
If the type of a call to `str` has already been deduced as
unicode (because of language_level=3), then keep that type.

This was causing optimizations to fail, where the optimization
was made on the basis that the type was unicode and then that
was reversed by the replacement of `str`.

Fixes cython#6166.

Most of this doesn't need to go into 3.1.
@da-woods da-woods linked a pull request Apr 29, 2024 that will close this issue
@matusvalo matusvalo linked a pull request May 12, 2024 that will close this issue
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 a pull request may close this issue.

2 participants