Skip to content

[BUG] casting PyObject * is broken in pure python mode #4243

@matusvalo

Description

@matusvalo

Describe the bug
For some cases casting PyObject * is failing during compilation with error: Cannot convert 'PyObject *' to Python object

To Reproduce
Following code is compiling with no error:

from cpython.ref cimport PyObject


foo = {"abc": 123}

cdef PyObject *bar = <PyObject *> foo

But in pure python version is failing:

import cython
from cython.cimports.cpython.ref import PyObject

foo = {"abc": 123}

bar: cython.pointer(PyObject) = cython.cast(cython.pointer(PyObject), foo)

Expected behavior

Pure python mode should reflect cython language.

Environment (please complete the following information):

  • OS: Linux
  • Python version: 3.9.2
  • Cython version: master branch

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions