-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when copying instances of Generic subclasses #498
Comments
Indeed, this is fixed by #468 (a.k.a. PEP 560), but the fix will be available only in Python 3.7. Therefore, I think it makes sense to also fix it in the backport (the crash also happens on Python 3.4). |
This was referenced Nov 24, 2017
ilevkivskyi
added a commit
that referenced
this issue
Nov 25, 2017
Fixes #498 (on both Python 2 and 3)
piotrmaslanka
added a commit
to piotrmaslanka/satella
that referenced
this issue
Mar 10, 2020
piotrmaslanka
added a commit
to piotrmaslanka/satella
that referenced
this issue
Mar 10, 2020
A solution that works: class MyClass(Generic[T]):
__copy__ = None
... This is safe:
A general hack can be also
(edited) It works in some of the first modules of an application before the first copy. Maybe this is also possible to do in typing_extensions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trying to do the following
produces
whereas there is no error if not inheriting from
Generic
.The most similar issue to this one is #458 but that snippet is trying to call
__copy__
directly instead ofcopy.copy
. There is also #306 but that one is trying to copy the type instead of an instance, and also switching the above snippet tocopy.deepcopy
does work. Finally, there is #468, it's possible that a fix for this issue would fall within its scope.The text was updated successfully, but these errors were encountered: