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-03 22:58:07 +0100
commitdeb6c36613379c9ca6c05c8290da0fba31e0a23c (patch)
treeeb558e34db7f2d5ced0adaa3e25e35be44afcde6
parent95bf3e767ea0e1a7b24014efeb4cfe07d81a6939 (diff)
downloadcython-gh884_docstrings.tar.gz
Support CPython builds with docstrings disabled by wrapping docstring literals in the `PyDoc_STR()` macro.gh884_docstrings
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):