Skip to content

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

@ghuls

Description

@ghuls

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions