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

Calling function in python extension module with wrong type crashes python. #630

Open
ghuls opened this issue Feb 27, 2025 · 0 comments
Open

Comments

@ghuls
Copy link

ghuls commented Feb 27, 2025

Compiling the following function to a python extension module and calling it with the wrong type, will crash the python interpreter instead of just trowing an exception:

$ cat wrong_type.codon
def wrong_arg(x: int):
    return x
ipython
Python 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:53:32) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.32.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import wrong_type

In [2]: wrong_type.wrong_arg(1)
Out[2]: 1

In [3]: wrong_type.wrong_arg(1.2)
PyError: conversion error: Python object did not have type 'int'

Raised from: std.internal.python._conversion_error:0
/software/codon/codon-0.18.1/lib/codon/stdlib/internal/python.codon:1293:5
Aborted (core dumped)
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

No branches or pull requests

1 participant