decls_writer = self.parts['decls']
for _, cname, c in c_consts:
decls_writer.putln('static char %s[] = "%s";' % (
- cname, StringEncoding.split_docstring(c.escaped_value)))
+ cname, StringEncoding.split_string_literal(c.escaped_value)))
if c.py_strings is not None:
for py_string in c.py_strings.itervalues():
py_strings.append((c.cname, len(py_string.cname), py_string))
StructOrUnionScope, PyClassScope, CClassScope, CppClassScope
from Cython.Utils import open_new_file, replace_suffix
from Code import UtilityCode
-from StringEncoding import EncodedString, escape_byte_string, split_docstring
+from StringEncoding import EncodedString, escape_byte_string, split_string_literal
import Options
import ControlFlow
import DebugFlags
code.putln(
'static char %s[] = "%s";' % (
self.entry.doc_cname,
- split_docstring(escape_byte_string(docstr))))
+ split_string_literal(escape_byte_string(docstr))))
if with_pymethdef:
code.put(
"static PyMethodDef %s = " %
append(c)
return join_bytes(l).decode('ISO-8859-1')
-def split_docstring(s):
+def split_string_literal(s):
# MSVC can't handle long string literals.
if len(s) < 2047:
return s
else:
- return '""'.join([s[i:i+2000] for i in range(0, len(s), 2000)])
+ return '""'.join([s[i:i+2000] for i in range(0, len(s), 2000)]).replace(r'\""', '""\\')