Commit 473b5df8 authored by Robert Bradshaw's avatar Robert Bradshaw

Allow direct conversion from char* to std::string.

Previously this was only possible through Python (requring the GIL),
sometimes implicitly (e.g. for string literals).
parent 5cf7be8f
...@@ -3730,6 +3730,8 @@ class CppClassType(CType): ...@@ -3730,6 +3730,8 @@ class CppClassType(CType):
return True return True
elif other_type.is_cpp_class: elif other_type.is_cpp_class:
return other_type.is_subclass(self) return other_type.is_subclass(self)
elif other_type.is_string and self.cname in cpp_string_conversions:
return True
def attributes_known(self): def attributes_known(self):
return self.scope is not None return self.scope is not None
......
...@@ -72,6 +72,16 @@ def test_string_call(a, b): ...@@ -72,6 +72,16 @@ def test_string_call(a, b):
""" """
return add_strings(a, b) return add_strings(a, b)
def test_c_string_convert(char *c_string):
"""
>>> normalize(test_c_string_convert("abc"))
'abc'
"""
cdef string s
with nogil:
s = c_string
return s
def test_int_vector(o): def test_int_vector(o):
""" """
>>> test_int_vector([1, 2, 3]) >>> test_int_vector([1, 2, 3])
......
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