Open
Description
The C type system is weak, compared to Java or Rust, but we should use it where possible.
The function PyTuple_Size()
should be infallible; all tuples have a size.
Yet, it can fail if passed a non-tuple, which can only happen because it is weakly typed.
Like PyTuple_Size(PyObject *)
, many API functions take PyObject *
when they should take more specific types.
Here are a few examples:
PyTuple_Size()
PyList_Append()
PyDict_GetItem()
The error handling of these functions is awful. PyTuple_Size()
and PyList_Append()
raise a SystemError
, not a TypeError
if passed the wrong type. PyDict_GetItem()
just acts as if the item is not in the container, not raising at all.