[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-15 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks, Serhiy! ✨  ✨

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-15 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 2746045a37e0d56ffdd8bb79f961bd7df0d1afba by Miss Islington (bot) 
in branch '3.9':
bpo-45167: Fix deepcopying of GenericAlias (GH-28324) (GH-28368)
https://github.com/python/cpython/commit/2746045a37e0d56ffdd8bb79f961bd7df0d1afba


--

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-15 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset de4c9c0bdc9b62e68dacd0c4bac20d7f4c527511 by Miss Islington (bot) 
in branch '3.10':
bpo-45167: Fix deepcopying of GenericAlias (GH-28324) (GH-28367)
https://github.com/python/cpython/commit/de4c9c0bdc9b62e68dacd0c4bac20d7f4c527511


--

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-15 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +26781
pull_request: https://github.com/python/cpython/pull/28367

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26782
pull_request: https://github.com/python/cpython/pull/28368

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-15 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 5dce51a8875d9639786741e962b3cb208596b096 by Serhiy Storchaka in 
branch 'main':
bpo-45167: Fix deepcopying of GenericAlias (GH-28324)
https://github.com/python/cpython/commit/5dce51a8875d9639786741e962b3cb208596b096


--

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +26734
pull_request: https://github.com/python/cpython/pull/28324

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I meant that the current __getattr__ breaks deepcopy(). It can break also other 
protocols. It already has a list of exceptions, we need to add "__copy__" and 
"__deepcopy__" in this list. Or maybe exclude all dunder names by default and 
use a white list?

--

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Łukasz Langa

Łukasz Langa  added the comment:

Serhiy, can you elaborate how GH-28306 can break protocols using other special 
methods? I can't come up with an example.

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I think it is better to narrow the __getattr__. It can break protocols using 
other special methods.

--
nosy: +gvanrossum, serhiy.storchaka

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
versions: +Python 3.10, Python 3.11

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-13 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
keywords: +patch
nosy: +uriyyo
nosy_count: 1.0 -> 2.0
pull_requests: +26720
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28306

___
Python tracker 

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



[issue45167] deepcopy of GenericAlias with __deepcopy__ method is broken

2021-09-10 Thread Jacob Hayes


New submission from Jacob Hayes :

When deepcopying a parametrized types.GenericAlias (eg: a dict subclass) that 
has a __deepcopy__ method, the copy module doesn't detect the GenericAlias as a 
type and instead tries to call cls.__deepcopy__, passing `memo` inplace of 
self. This doesn't seem to happen with `typing.Generic` however.

Example:
```
from copy import deepcopy


class X(dict):
def __deepcopy__(self, memo):
return self


print(deepcopy(X()))
print(deepcopy(X))

print(type(X[str, int]))
print(deepcopy(X[str, int]()))
print(deepcopy(X[str, int]))
```
shows
```
{}


{}
Traceback (most recent call last):
  File "/tmp/demo.py", line 14, in 
print(deepcopy(X[str, int]))
  File "/Users/jacobhayes/.pyenv/versions/3.9.6/lib/python3.9/copy.py", line 
153, in deepcopy
y = copier(memo)
TypeError: __deepcopy__() missing 1 required positional argument: 'memo'
```

I don't know if it's better to update `copy.deepcopy` here or perhaps narrow 
the `__getattr__` for `types.GenericAlias` (as `typing. _BaseGenericAlias` 
seems to).

--
components: Library (Lib)
messages: 401601
nosy: JacobHayes
priority: normal
severity: normal
status: open
title: deepcopy of GenericAlias with __deepcopy__ method is broken
type: behavior
versions: Python 3.9

___
Python tracker 

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