Commit 19468dd9 authored by Stefan Behnel's avatar Stefan Behnel

Support CPython builds with docstrings disabled by wrapping docstring literals...

Support CPython builds with docstrings disabled by wrapping docstring literals in the `PyDoc_STR()` macro.
Closes GH-884.
parent d6ea7356
...@@ -2209,7 +2209,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2209,7 +2209,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if doc: if doc:
if doc.is_unicode: if doc.is_unicode:
doc = doc.as_utf8_string() doc = doc.as_utf8_string()
doc_code = doc.as_c_string_literal() doc_code = "PyDoc_STR(%s)" % doc.as_c_string_literal()
else: else:
doc_code = "0" doc_code = "0"
code.putln( code.putln(
......
...@@ -3483,7 +3483,7 @@ class DefNodeWrapper(FuncDefNode): ...@@ -3483,7 +3483,7 @@ class DefNodeWrapper(FuncDefNode):
docstr = docstr.as_utf8_string() docstr = docstr.as_utf8_string()
if not (entry.is_special and entry.name in ('__getbuffer__', '__releasebuffer__')): 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, entry.doc_cname,
docstr.as_c_string_literal())) docstr.as_c_string_literal()))
......
...@@ -446,7 +446,7 @@ class DocStringSlot(SlotDescriptor): ...@@ -446,7 +446,7 @@ class DocStringSlot(SlotDescriptor):
return "0" return "0"
if doc.is_unicode: if doc.is_unicode:
doc = doc.as_utf8_string() doc = doc.as_utf8_string()
return doc.as_c_string_literal() return "PyDoc_STR(%s)" % doc.as_c_string_literal()
class SuiteSlot(SlotDescriptor): class SuiteSlot(SlotDescriptor):
......
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