Commit 038812a7 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2385 from gabrieldemarmiesse/test_string_10

Adding tests for "Unicode and passing strings" part 10
parents b1667e9e f72b9bd0
# distutils: language = c++
from libcpp.string cimport string
def get_bytes():
py_bytes_object = b'hello world'
cdef string s = py_bytes_object
s.append('abc')
py_bytes_object = s
return py_bytes_object
......@@ -345,18 +345,9 @@ C++ strings
When wrapping a C++ library, strings will usually come in the form of
the :c:type:`std::string` class. As with C strings, Python byte strings
automatically coerce from and to C++ strings::
automatically coerce from and to C++ strings:
# distutils: language = c++
from libcpp.string cimport string
cdef string s = py_bytes_object
try:
s.append('abc')
py_bytes_object = s
finally:
del s
.. literalinclude:: ../../examples/tutorial/string/cpp_string.pyx
The memory management situation is different than in C because the
creation of a C++ string makes an independent copy of the string
......
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