Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
edde08f7
Commit
edde08f7
authored
Mar 17, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix comparison of templates when mixing "const" with typedefs.
See #2148.
parent
e9423fd9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
CHANGES.rst
CHANGES.rst
+4
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+6
-0
tests/run/cpp_smart_ptr.pyx
tests/run/cpp_smart_ptr.pyx
+11
-6
No files found.
CHANGES.rst
View file @
edde08f7
...
...
@@ -14,6 +14,10 @@ Bugs fixed
* ``PyFrozenSet_New()`` was accidentally used in PyPy where it is lacking
from the C-API.
* Assignment between some C++ templated types were incorrectly rejected
when the templates mix ``const`` with ``ctypedef``.
(Github issue #2148)
0.28 (2018-03-13)
=================
...
...
Cython/Compiler/PyrexTypes.py
View file @
edde08f7
...
...
@@ -1595,6 +1595,12 @@ class CConstType(BaseType):
self
.
to_py_function
=
self
.
const_base_type
.
to_py_function
return
True
def
same_as_resolved_type
(
self
,
other_type
):
if
other_type
.
is_const
:
return
self
.
const_base_type
.
same_as_resolved_type
(
other_type
.
const_base_type
)
# Accept const LHS <- non-const RHS.
return
self
.
const_base_type
.
same_as_resolved_type
(
other_type
)
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
const_base_type
,
name
)
...
...
tests/run/cpp_smart_ptr.pyx
View file @
edde08f7
# distutils: extra_compile_args=-std=c++0x
# mode: run
# tag: cpp, werror
# tag: cpp, werror, cpp11
# distutils: extra_compile_args=-std=c++0x
from
libcpp.memory
cimport
unique_ptr
,
shared_ptr
,
default_delete
from
libcpp
cimport
nullptr
...
...
@@ -12,6 +12,10 @@ cdef extern from "cpp_smart_ptr_helper.h":
cdef
cppclass
FreePtr
[
T
]:
pass
ctypedef
const
CountAllocDealloc
const_CountAllocDealloc
def
test_unique_ptr
():
"""
>>> test_unique_ptr()
...
...
@@ -42,17 +46,18 @@ def test_unique_ptr():
x_ptr3
.
reset
()
assert
x_ptr3
.
get
()
==
nullptr
;
def
test_shared_ptr
():
def
test_const_shared_ptr
():
"""
>>> test_shared_ptr()
>>> test_
const_
shared_ptr()
"""
cdef
int
alloc_count
=
0
,
dealloc_count
=
0
cdef
shared_ptr
[
CountAllocDealloc
]
ptr
=
shared_ptr
[
CountAllocDealloc
](
cdef
shared_ptr
[
const
CountAllocDealloc
]
ptr
=
shared_ptr
[
const_
CountAllocDealloc
](
new
CountAllocDealloc
(
&
alloc_count
,
&
dealloc_count
))
assert
alloc_count
==
1
assert
dealloc_count
==
0
cdef
shared_ptr
[
CountAllocDealloc
]
ptr2
=
ptr
cdef
shared_ptr
[
const
CountAllocDealloc
]
ptr2
=
ptr
assert
alloc_count
==
1
assert
dealloc_count
==
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment