Commit cb5eb5a1 authored by da-woods's avatar da-woods Committed by GitHub

Fix cython.pointer() type usage in class annotations (GH-4515)

Annotations attached to namenodes weren't correctly processed with "InterpretCompilerDirectivesTransform"

Closes https://github.com/cython/cython/issues/4514
parent 9d60179a
......@@ -913,6 +913,8 @@ class InterpretCompilerDirectives(CythonTransform):
return node
def visit_NameNode(self, node):
if node.annotation:
self.visit(node.annotation)
if node.name in self.cython_module_names:
node.is_cython_module = True
else:
......
......@@ -278,6 +278,21 @@ def call_take_ptr():
python_dict = {"abc": 123}
take_ptr(cython.cast(cython.pointer(PyObject), python_dict))
@cython.cclass
class HasPtr:
"""
>>> HasPtr()
HasPtr(1, 1)
"""
a: cython.pointer(cython.int)
b: cython.int
def __init__(self):
self.b = 1
self.a = cython.address(self.b)
def __repr__(self):
return f"HasPtr({self.a[0]}, {self.b})"
_WARNINGS = """
9:32: Strings should no longer be used for type declarations. Use 'cython.int' etc. directly.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment