8000 [3.6] bpo-31926: fix missing *_METHODDEF statements by argument clini… · python/cpython@f8b3f6b · GitHub
[go: up one dir, main page]

Skip to content

Commit f8b3f6b

Browse files
taleinatvstinner
authored andcommitted
[3.6] bpo-31926: fix missing *_METHODDEF statements by argument clinic (GH-4230) (#4253)
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 4f57409)
1 parent 019c99f commit f8b3f6b

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed Argument Clinic sometimes causing compilation errors when there was
2+
more than one function and/or method in a .c file with the same name.

Modules/clinic/zlibmodule.c.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,8 @@ zlib_crc32(PyObject *module, PyObject *args)
467467
#ifndef ZLIB_COMPRESS_COPY_METHODDEF
468468
#define ZLIB_COMPRESS_COPY_METHODDEF
469469
#endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */
470-
/*[clinic end generated code: output=3a4e2bfe750423a3 input=a9049054013a1b77]*/
470+
471+
#ifndef ZLIB_DECOMPRESS_COPY_METHODDEF
472+
#define ZLIB_DECOMPRESS_COPY_METHODDEF
473+
#endif /* !defined(ZLIB_DECOMPRESS_COPY_METHODDEF) */
474+
/*[clinic end generated code: output=497dad1132c962e2 input=a9049054013a1b77]*/

Modules/zlibmodule.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,19 +1149,15 @@ static PyMethodDef comp_methods[] =
11491149
{
11501150
ZLIB_COMPRESS_COMPRESS_METHODDEF
11511151
ZLIB_COMPRESS_FLUSH_METHODDEF
1152-
#ifdef HAVE_ZLIB_COPY
11531152
ZLIB_COMPRESS_COPY_METHODDEF
1154-
#endif
11551153
{NULL, NULL}
11561154
};
11571155

11581156
static PyMethodDef Decomp_methods[] =
11591157
{
11601158
ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF
11611159
ZLIB_DECOMPRESS_FLUSH_METHODDEF
1162-
#ifdef HAVE_ZLIB_COPY
11631160
ZLIB_DECOMPRESS_COPY_METHODDEF
1164-
#endif
11651161
{NULL, NULL}
11661162
};
11671163

Tools/clinic/clinic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,8 @@ def insert_keywords(s):
928928
cpp_if = "#if " + conditional
929929
cpp_endif = "#endif /* " + conditional + " */"
930930

931-
if methoddef_define and f.name not in clinic.ifndef_symbols:
932-
clinic.ifndef_symbols.add(f.name)
931+
if methoddef_define and f.full_name not in clinic.ifndef_symbols:
932+
clinic.ifndef_symbols.add(f.full_name)
933933
methoddef_ifndef = normalize_snippet("""
934934
#ifndef {methoddef_name}
935935
#define {methoddef_name}

0 commit comments

Comments
 (0)
0