]> granicus.if.org Git - python/commitdiff
bpo-31926: fix missing *_METHODDEF statements by argument clinic (#4230)
authorTal Einat <taleinat@gmail.com>
Fri, 3 Nov 2017 09:09:00 +0000 (11:09 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 3 Nov 2017 09:09:00 +0000 (11:09 +0200)
When a single .c file contains several functions and/or methods with
the same name, a safety _METHODDEF #define statement is generated
only for one of them.

This fixes the bug by using the full name of the function to avoid
duplicates rather than just the name.

Misc/NEWS.d/next/Build/2017-11-03-10-07-14.bpo-31926.57wE98.rst [new file with mode: 0644]
Modules/clinic/zlibmodule.c.h
Modules/zlibmodule.c
Tools/clinic/clinic.py

diff --git a/Misc/NEWS.d/next/Build/2017-11-03-10-07-14.bpo-31926.57wE98.rst b/Misc/NEWS.d/next/Build/2017-11-03-10-07-14.bpo-31926.57wE98.rst
new file mode 100644 (file)
index 0000000..2a42104
--- /dev/null
@@ -0,0 +1,2 @@
+Fixed Argument Clinic sometimes causing compilation errors when there was
+more than one function and/or method in a .c file with the same name.
index 3edf7db7c2f90c8c13bc4c8a8999896401785d40..33c767236bbd8765904d8fc7af94567f80fc08f9 100644 (file)
@@ -467,4 +467,8 @@ exit:
 #ifndef ZLIB_COMPRESS_COPY_METHODDEF
     #define ZLIB_COMPRESS_COPY_METHODDEF
 #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */
-/*[clinic end generated code: output=e0184313eb431e95 input=a9049054013a1b77]*/
+
+#ifndef ZLIB_DECOMPRESS_COPY_METHODDEF
+    #define ZLIB_DECOMPRESS_COPY_METHODDEF
+#endif /* !defined(ZLIB_DECOMPRESS_COPY_METHODDEF) */
+/*[clinic end generated code: output=6378d429f0819817 input=a9049054013a1b77]*/
index cf086de7573b311e3f0240ce4b0b8d68e2fb3af8..cb2aae106944e1b0da08d12a9cbd7d041f72c6c9 100644 (file)
@@ -1138,9 +1138,7 @@ static PyMethodDef comp_methods[] =
 {
     ZLIB_COMPRESS_COMPRESS_METHODDEF
     ZLIB_COMPRESS_FLUSH_METHODDEF
-#ifdef HAVE_ZLIB_COPY
     ZLIB_COMPRESS_COPY_METHODDEF
-#endif
     {NULL, NULL}
 };
 
@@ -1148,9 +1146,7 @@ static PyMethodDef Decomp_methods[] =
 {
     ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF
     ZLIB_DECOMPRESS_FLUSH_METHODDEF
-#ifdef HAVE_ZLIB_COPY
     ZLIB_DECOMPRESS_COPY_METHODDEF
-#endif
     {NULL, NULL}
 };
 
index 91d8440e14a772142ef960d08f27df5e8a5faaa6..4cdfebb5107497371d048bf6eafc389a0ba502a0 100755 (executable)
@@ -957,8 +957,8 @@ class CLanguage(Language):
             cpp_if = "#if " + conditional
             cpp_endif = "#endif /* " + conditional + " */"
 
-            if methoddef_define and f.name not in clinic.ifndef_symbols:
-                clinic.ifndef_symbols.add(f.name)
+            if methoddef_define and f.full_name not in clinic.ifndef_symbols:
+                clinic.ifndef_symbols.add(f.full_name)
                 methoddef_ifndef = normalize_snippet("""
                     #ifndef {methoddef_name}
                         #define {methoddef_name}