8000 bpo-31926: fix missing *_METHODDEF statements by argument clinic (#4230) · python/cpython@4f57409 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f57409

Browse files
taleinatserhiy-storchaka
authored andcommitted
bpo-31926: fix missing *_METHODDEF statements by argument clinic (#4230)
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.
1 parent 700d2e4 commit 4f57409

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, Py_ssize_t nargs)
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=e0184313eb431e95 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=6378d429f0819817 input=a9049054013a1b77]*/

Modules/zlibmodule.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,19 +1138,15 @@ static PyMethodDef comp_methods[] =
11381138
{
11391139
ZLIB_COMPRESS_COMPRESS_METHODDEF
11401140
ZLIB_COMPRESS_FLUSH_METHODDEF
1141-
#ifdef HAVE_ZLIB_COPY
11421141
ZLIB_COMPRESS_COPY_METHODDEF
1143-
#endif
11441142
{NULL, NULL}
11451143
};
11461144

11471145
static PyMethodDef Decomp_methods[] =
11481146
{
11491147
ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF
11501148
ZLIB_DECOMPRESS_FLUSH_METHODDEF
1151-
#ifdef HAVE_ZLIB_COPY
11521149
ZLIB_DECOMPRESS_COPY_METHODDEF
1153-
#endif
11541150
{NULL, NULL}
11551151
};
11561152

Tools/clinic/clinic.py

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

960-
if methoddef_define and f.name not in clinic.ifndef_symbols:
961-
clinic.ifndef_symbols.add(f.name)
960+
if methoddef_define and f.full_name not in clinic.ifndef_symbols:
961+
clinic.ifndef_symbols.add(f.full_name)
962962
methoddef_ifndef = normalize_snippet("""
963963
#ifndef {methoddef_name}
964964
#define {methoddef_name}

0 commit comments

Comments
 (0)
0