From deb6c36613379c9ca6c05c8290da0fba31e0a23c Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 3 Mar 2019 22:58:07 +0100 Subject: Support CPython builds with docstrings disabled by wrapping docstring literals in the `PyDoc_STR()` macro. Closes GH-884. --- Cython/Compiler/ModuleNode.py | 2 +- Cython/Compiler/Nodes.py | 2 +- Cython/Compiler/TypeSlots.py | 2 +- 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): -- cgit v1.2.1