diff options
author | Yue Yang <metab0t@users.noreply.github.com> | 2023-04-20 15:57:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-20 09:57:14 +0200 |
commit | cfb9973aff60fe01747020de94bb30c0e306c5bd (patch) | |
tree | 78c3aa99eccd05250a4feb687e3d6dc038a3c77c | |
parent | 2a2608081dab528b2e28a3c729c049436e7ce8e6 (diff) | |
download | cython-cfb9973aff60fe01747020de94bb30c0e306c5bd.tar.gz |
Make memoryviews with aliased item types comformable (GH-5375)
-rw-r--r-- | Cython/Compiler/PyrexTypes.py | 2 | ||||
-rw-r--r-- | tests/memoryview/memoryview.pyx | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index d32e93414..b20085048 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -871,7 +871,7 @@ class MemoryViewSliceType(PyrexType): if dst_dtype.is_cv_qualified: dst_dtype = dst_dtype.cv_base_type - if src_dtype != dst_dtype: + if not src_dtype.same_as(dst_dtype): return False if src.ndim != dst.ndim: diff --git a/tests/memoryview/memoryview.pyx b/tests/memoryview/memoryview.pyx index 2c5de40b5..344d11840 100644 --- a/tests/memoryview/memoryview.pyx +++ b/tests/memoryview/memoryview.pyx @@ -1240,3 +1240,18 @@ match arr: assert globs['res'] return isinstance(<object>a, Sequence) + + +ctypedef int aliasT +def test_assignment_typedef(): + """ + >>> test_assignment_typedef() + 1 + 2 + """ + cdef int[2] x + cdef aliasT[:] y + x[:] = [1, 2] + y = x + for v in y: + print(v) |