Message155227
>>> 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. |
|
Date |
User |
Action |
Args |
2012-03-09 12:39:16 | Mark.Shannon | set | recipients:
+ Mark.Shannon |
2012-03-09 12:39:16 | Mark.Shannon | set | messageid: <1331296756.01.0.329340447456.issue14241@psf.upfronthosting.co.za> |
2012-03-09 12:39:15 | Mark.Shannon | link | issue14241 messages |
2012-03-09 12:39:15 | Mark.Shannon | create | |
|