[issue43824] array.array.__deepcopy__() accepts a parameter of any type

2021-04-13 Thread MingZhe Hu


MingZhe Hu  added the comment:

copy.deepcopy() takes a memo argument for reason, but this memo object will not 
be used when passed to array.array.__deepcopy__(), that is, no matter called 
directly or not, as long as the C implementation of array.array.__deepcopy__() 
does not use the parameter(s) passed from the Python side, why not declare it 
using flag `METH_NOARGS`?

If I understand right, in following code, the memo passed to __deepcopy__() is 
meaningless:

https://github.com/python/cpython/blob/a4833883c9b81b6b272cc7c5b67fa1658b65304c/Lib/copy.py#L151-L153

--

___
Python tracker 
<https://bugs.python.org/issue43824>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43824] array.array.__deepcopy__() accepts a parameter of any type

2021-04-12 Thread MingZhe Hu


New submission from MingZhe Hu :

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

https://github.com/python/cpython/blob/d9151cb45371836d39b6d53afb50c5bcd353c661/Modules/arraymodule.c#L855

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:

https://github.com/python/cpython/blob/d9151cb45371836d39b6d53afb50c5bcd353c661/Modules/clinic/arraymodule.c.h#L30

This makes the following code legal:

```
import array
a = array.array('b',  [ord('g')])
a.__deepcopy__('str')
a.__deepcopy__(1)
a.__deepcopy__([1,'str'])
```

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 
<https://bugs.python.org/issue43824>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41624] typing.Coroutine documentation

2020-08-24 Thread MingZhe Hu


Change by MingZhe Hu :


--
keywords: +patch
pull_requests: +21061
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21952

___
Python tracker 
<https://bugs.python.org/issue41624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41624] typing.Coroutine documentation

2020-08-24 Thread MingZhe Hu


New submission from MingZhe Hu :

The documentation [1] for Coroutine in typing library writes:

class typing.Coroutine(Awaitable[V_co], Generic[T_co T_contra, V_co])

which should be:

class typing.Coroutine(Awaitable[V_co], Generic[T_co, T_contra, V_co])

a comma is missed between the first type variable T_co and the second one 
T_contr.

[1] https://docs.python.org/3/library/typing.html#typing.Generic

--
assignee: docs@python
components: Documentation
messages: 375841
nosy: Elaphurus, docs@python
priority: normal
severity: normal
status: open
title: typing.Coroutine documentation
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue41624>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com