diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 51db4963737e47b1eed1b6d1e4a1c5f2ebd9cd09..5957163c60b589fce60ae7bc4f08cc05e7d5d7c8 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -782,11 +782,10 @@ class ExprNode(Node): if src.constant_result is not None: src = PyTypeTestNode(src, dst_type, env) elif src.type.is_pyobject: - if used_as_reference: + if used_as_reference and dst_type.is_cpp_class: warning( self.pos, - "Cannot pass Python object as C++ data structure reference (%s &), will pass by copy." % dst_type, - level=1) + "Cannot pass Python object as C++ data structure reference (%s &), will pass by copy." % dst_type) src = CoerceFromPyTypeNode(dst_type, src, env) elif (dst_type.is_complex and src_type != dst_type