Skip to content

Assertion failed: typeinfo->proto in PyCPointerType_from_param_impl when using deprecated POINTER(str) in argtypes #144100

Closed

Description

@YuanchengJiang

Bug report

Bug description:

import ctypes

# The specific bug is triggered by creating a POINTER type using a string 
# (which issues a DeprecationWarning) and then using it for argument conversion.
BadType = ctypes.POINTER("BugTrigger")

# Load standard library (Linux/POSIX specific, matches the crash environment)
libc = ctypes.CDLL(None)

# Use any standard function (e.g., getpid) to attach argtypes
func = libc.getpid
func.argtypes = (BadType,)

try:
    # Calling the function forces ctypes to run PyCPointerType_from_param_impl
    # on the argument, triggering the "Assertion `typeinfo->proto' failed".
    func(ctypes.byref(ctypes.c_int(0)))
except Exception:
    pass
python: ../Modules/_ctypes/_ctypes.c:1422: PyObject *PyCPointerType_from_param_impl(PyObject *, PyTypeObject *, PyObject *): Assertion `typeinfo->proto' failed.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added a commit that references this issue on Jan 21, 2026
  2. added a commit that references this issue on Jan 26, 2026
  3. added a commit that references this issue on Jan 26, 2026
  4. vstinner commented on Jan 26, 2026

    @vstinner
    Member

    Fixed. Thanks for the bug report.

  5. added 2 commits that reference this issue on Jan 26, 2026
  6. added a commit that references this issue on Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions