]> granicus.if.org Git - python/commitdiff
[3.6] bpo-31926: fix missing *_METHODDEF statements by argument clinic (GH-4230)...
authorTal Einat <taleinat@gmail.com>
Fri, 3 Nov 2017 13:43:13 +0000 (15:43 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 3 Nov 2017 13:43:13 +0000 (06:43 -0700)
When a single .c file contains several functions and/or methods with
the same name, a safety _METHODDEF GH-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..
(cherry picked from commit 4f57409a2f7bdf8fb559cddc7c6533ca2c471c67)

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 fda392a9cde38f169e97f152cb47a7f701623a59..7339596d22fd92ac2c6add1082f71bc8ed0c1813 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=3a4e2bfe750423a3 input=a9049054013a1b77]*/
+
+#ifndef ZLIB_DECOMPRESS_COPY_METHODDEF
+    #define ZLIB_DECOMPRESS_COPY_METHODDEF
+#endif /* !defined(ZLIB_DECOMPRESS_COPY_METHODDEF) */
+/*[clinic end generated code: output=497dad1132c962e2 input=a9049054013a1b77]*/
index cfe7f88dc540ecb1edb4aa6b145af5075efa7dce..29f55bdb19c6d5a92bd291d1a6137434f55867a4 100644 (file)
@@ -1149,9 +1149,7 @@ static PyMethodDef comp_methods[] =
 {
     ZLIB_COMPRESS_COMPRESS_METHODDEF
     ZLIB_COMPRESS_FLUSH_METHODDEF
-#ifdef HAVE_ZLIB_COPY
     ZLIB_COMPRESS_COPY_METHODDEF
-#endif
     {NULL, NULL}
 };
 
@@ -1159,9 +1157,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 75ac673737edbb48fc24004a2a244f502fe62333..f8663f0a521393322b3f4241739112802c2d831c 100755 (executable)
@@ -928,8 +928,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}