]> granicus.if.org Git - python/commitdiff
bpo-36641: Add "const" to PyDoc_VAR macro (GH-12854)
authorInada Naoki <songofacandy@gmail.com>
Tue, 16 Apr 2019 23:39:46 +0000 (08:39 +0900)
committerGitHub <noreply@github.com>
Tue, 16 Apr 2019 23:39:46 +0000 (08:39 +0900)
It reduces "data" segment in python about 200KB.

Include/pymacro.h
Misc/NEWS.d/next/C API/2019-04-16-21-18-19.bpo-36641.pz-DIR.rst [new file with mode: 0644]
Modules/_ssl.c

index 3f6ddbe9977acec2a9d2f95f0d0b91ecec538e80..546f9c6e7020254cb9c46bb8f987dcda04e1fa6f 100644 (file)
@@ -67,7 +67,7 @@
 
 
 /* Define macros for inline documentation. */
-#define PyDoc_VAR(name) static char name[]
+#define PyDoc_VAR(name) static const char name[]
 #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
 #ifdef WITH_DOC_STRINGS
 #define PyDoc_STR(str) str
diff --git a/Misc/NEWS.d/next/C API/2019-04-16-21-18-19.bpo-36641.pz-DIR.rst b/Misc/NEWS.d/next/C API/2019-04-16-21-18-19.bpo-36641.pz-DIR.rst
new file mode 100644 (file)
index 0000000..f92af63
--- /dev/null
@@ -0,0 +1,2 @@
+:c:macro:`PyDoc_VAR(name)` and :c:macro:`PyDoc_STRVAR(name,str)` now create
+``static const char name[]`` instead of ``static char name[]``.  Patch by Inada Naoki.
index f8ae916735f44090e2ae04b4d1a1c3234d474f68..e75e3466dd3f2a63bc0b05eb3e113c7d78b62bbd 100644 (file)
@@ -557,7 +557,7 @@ SSLError_str(PyOSErrorObject *self)
 
 static PyType_Slot sslerror_type_slots[] = {
     {Py_tp_base, NULL},  /* Filled out in module init as it's not a constant */
-    {Py_tp_doc, SSLError_doc},
+    {Py_tp_doc, (void*)SSLError_doc},
     {Py_tp_str, SSLError_str},
     {0, 0},
 };