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

Use an EncodedString on dataclass types when creating a StringNode (GH-4728)

Closes https://github.com/cython/cython/issues/4704
parent 18eb280a
......@@ -590,7 +590,7 @@ def get_field_type(pos, entry):
# try to return PyType_Type. This case should only happen with
# attributes defined with cdef so Cython is free to make it's own
# decision
s = entry.type.declaration_code("", for_display=1)
s = EncodedString(entry.type.declaration_code("", for_display=1))
return ExprNodes.StringNode(pos, value=s)
......
......@@ -197,12 +197,20 @@ cdef class TestVisibility:
'double'
>>> hasattr(inst, "c")
True
>>> "d" in TestVisibility.__dataclass_fields__
True
>>> TestVisibility.__dataclass_fields__["d"].type
'object'
>>> hasattr(inst, "d")
True
"""
cdef double a
a = 1.0
b: double = 2.0
cdef public double c
c = 3.0
cdef public object d
d = object()
@dataclass(frozen=True)
cdef class TestFrozen:
......
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