This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年03月09日 12:39 by Mark.Shannon, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| io_new.patch | Mark.Shannon, 2012年03月09日 12:39 | review | ||
| Messages (2) | |||
|---|---|---|---|
| msg155227 - (view) | Author: Mark Shannon (Mark.Shannon) * (Python committer) | Date: 2012年03月09日 12:39 | |
>>> 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. |
|||
| msg164849 - (view) | Author: Mark Shannon (Mark.Shannon) * (Python committer) | Date: 2012年07月07日 14:03 | |
>>> io.UnsupportedOperation.__new__(io.UnsupportedOperation) behaves correctly now (rev d9c98730e2e8) This bug was (I believe) caused somehow by an error in OSError_new() which did not initialize self->args if OSError_init() was not called. Here is a crash which exploited the lack of initialization: (Works on rev 2a142141e5fd) >>> class C(ValueError, OSError):pass ... >>> c = OSError.__new__(C) >>> str(c) Segmentation fault (core dumped) This has already been fixed, so I'm closing this issue. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:27 | admin | set | github: 58449 |
| 2012年07月07日 14:48:49 | benjamin.peterson | set | resolution: fixed -> out of date |
| 2012年07月07日 14:03:22 | Mark.Shannon | set | status: open -> closed assignee: eric.araujo components: + Distutils2, - Interpreter Core nosy: + alexis, tarek messages: + msg164849 resolution: fixed |
| 2012年07月07日 09:51:20 | pitrou | set | nosy:
+ ncoghlan |
| 2012年07月07日 09:43:03 | larry | set | nosy:
+ larry |
| 2012年03月22日 04:57:07 | eric.araujo | set | nosy:
+ pitrou |
| 2012年03月10日 02:28:24 | eric.araujo | set | nosy:
+ eric.araujo |
| 2012年03月10日 00:26:34 | terry.reedy | set | stage: patch review versions: + Python 3.3 |
| 2012年03月09日 14:35:00 | pitrou | set | nosy:
+ benjamin.peterson |
| 2012年03月09日 12:39:15 | Mark.Shannon | create | |