diff -r 7bc53cf8b2df Include/pymacro.h --- a/Include/pymacro.h Mon Aug 04 11:18:23 2014 -0500 +++ b/Include/pymacro.h Mon Aug 04 15:37:20 2014 -0500 @@ -63,8 +63,10 @@ #define PyDoc_VAR(name) static char name[] #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) #ifdef WITH_DOC_STRINGS +#define PyDoc_VAR_WITH_SIZE(name, size) static char name[size] #define PyDoc_STR(str) str #else +#define PyDoc_VAR_WITH_SIZE(name, size) static char name[1] #define PyDoc_STR(str) "" #endif diff -r 7bc53cf8b2df Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py Mon Aug 04 11:18:23 2014 -0500 +++ b/Tools/clinic/clinic.py Mon Aug 04 15:37:20 2014 -0500 @@ -616,7 +616,7 @@ docstring_prototype = docstring_definition = '' else: docstring_prototype = normalize_snippet(""" - PyDoc_VAR({c_basename}__doc__); + PyDoc_VAR_WITH_SIZE({c_basename}__doc__, {docstring_size}); """) docstring_definition = normalize_snippet(""" PyDoc_STRVAR({c_basename}__doc__, @@ -1049,6 +1049,7 @@ template_dict['methoddef_name'] = methoddef_name template_dict['docstring'] = self.docstring_for_c_string(f) + template_dict['docstring_size'] = len(f.docstring) + 1 template_dict['self_name'] = template_dict['self_type'] = template_dict['self_type_check'] = '' f_self.converter.set_template_dict(template_dict)