New submission from ppperry <maprea...@olum.org>:

If you have a class that defines __new__ to the __new__ of another builtin type 
that it isn't a subclass of:
>>> class X:
...    __new__ = tuple.__new__
Instantiating this class should produce an error because `tuple.__new__` can't 
handle non-tuples, but instead it succeeds:
>>> X()
<__main__.X object at 0x00000000032C3F98>

(related: issue34284)

----------
components: Interpreter Core
messages: 323297
nosy: Vadim Pushtaev, ncoghlan, ppperry, serhiy.storchaka
priority: normal
severity: normal
status: open
title: User-created types with wrong __new__ can be instantiated
type: behavior
versions: Python 2.7, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34362>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to