[New-bugs-announce] [issue43824] array.array.__deepcopy__() accepts a parameter of any type

MingZhe Hu report at bugs.python.org
Mon Apr 12 23:00:23 EDT 2021

New submission from MingZhe Hu <humingzhework at 163.com>:

The C implementation of foreign function array.array.__deepcopy__() is declared as follows:


The second argument is unused in the function body.

However, corresponding PyMethodDef is declared with `METH_O` flag, meaning one parameter should be passed to array.array.__deepcopy__() from the Python side:


This makes the following code legal:

import array
a = array.array('b',  [ord('g')])

A parameter of ANY type can be passed to the foreign function, without effect on its semantic.

These code are clinic generated, and similar problems can be found for more foreign functions.

components: Argument Clinic, Extension Modules
messages: 390918
nosy: Elaphurus, larry
priority: normal
severity: normal
status: open
title: array.array.__deepcopy__() accepts a parameter of any type
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list