New submission from Mark Shannon <m...@hotpy.org>: >>> io.UnsupportedOperation.__new__(io.UnsupportedOperation) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ValueError.__new__(UnsupportedOperation) is not safe, use OSError.__new__()
Looking at the mro of io.UnsupportedOperation (io.UnsupportedOperation, ValueError, OSError, Exception, BaseException, object'>) Shows that ValueError.__new__ is getting called, but will not construct an instance of a subtype of OSError Switching the order of ValueError and OSError fixes this error (patch attached), but doesn't fix the underlying problem. Why doesn't io.UnsupportedOperation() fail, when UnsupportedOperation.__new__ does? io.UnsupportedOperation() actually calls OSError.__new__ via the internal tp_new slot. In other words UnsupportedOperation->tp_new != UnsupportedOperation.__new__ This should not happen, it looks like the logic in inherit_special() in typeobject.c may be faulty. ---------- components: Interpreter Core files: io_new.patch keywords: patch messages: 155227 nosy: Mark.Shannon priority: normal severity: normal status: open title: io.UnsupportedOperation.__new__(io.UnsupportedOperation) fails type: behavior Added file: http://bugs.python.org/file24768/io_new.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14241> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com