summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2019-03-03 22:58:07 +0100
committerStefan Behnel <stefan_ml@behnel.de>2019-03-04 13:15:51 +0100
commit19468dd99be65269f3c54fabb599efdbc44127d9 (patch)
tree05d6d0b4507ed28bbb928be35eaba42e6fa05f1c
parentd6ea7356b28b7f5a41893a810e11315bb5af8ec5 (diff)
downloadcython-19468dd99be65269f3c54fabb599efdbc44127d9.tar.gz
Support CPython builds with docstrings disabled by wrapping docstring literals in the `PyDoc_STR()` macro.
Closes GH-884.
-rw-r--r--Cython/Compiler/ModuleNode.py2
-rw-r--r--Cython/Compiler/Nodes.py2
-rw-r--r--Cython/Compiler/TypeSlots.py2
3 files changed, 3 insertions, 3 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
index 62f027d2c..71d97de97 100644
--- a/Cython/Compiler/ModuleNode.py
+++ b/Cython/Compiler/ModuleNode.py
@@ -2209,7 +2209,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if doc:
if doc.is_unicode:
doc = doc.as_utf8_string()
- doc_code = doc.as_c_string_literal()
+ doc_code = "PyDoc_STR(%s)" % doc.as_c_string_literal()
else:
doc_code = "0"
code.putln(
diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py
index 115841d7f..c71349a98 100644
--- a/Cython/Compiler/Nodes.py
+++ b/Cython/Compiler/Nodes.py
@@ -3483,7 +3483,7 @@ class DefNodeWrapper(FuncDefNode):
docstr = docstr.as_utf8_string()
if not (entry.is_special and entry.name in ('__getbuffer__', '__releasebuffer__')):
- code.putln('static char %s[] = %s;' % (
+ code.putln('PyDoc_STRVAR(%s, %s);' % (
entry.doc_cname,
docstr.as_c_string_literal()))
diff --git a/Cython/Compiler/TypeSlots.py b/Cython/Compiler/TypeSlots.py
index 39a3c9ee5..4a91b7d59 100644
--- a/Cython/Compiler/TypeSlots.py
+++ b/Cython/Compiler/TypeSlots.py
@@ -446,7 +446,7 @@ class DocStringSlot(SlotDescriptor):
return "0"
if doc.is_unicode:
doc = doc.as_utf8_string()
- return doc.as_c_string_literal()
+ return "PyDoc_STR(%s)" % doc.as_c_string_literal()
class SuiteSlot(SlotDescriptor):