classification
Title: segmentation fault when unicode(classic_class_instance)
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, draftcode, jcea, python-dev
Priority: normal Keywords: patch

Created on 2013-01-02 13:50 by draftcode, last changed 2013-01-02 20:44 by jcea. This issue is now closed.

Files
File name Uploaded Description Edit
object_unicode.patch draftcode, 2013-01-02 13:50 review
Messages (3)
msg178811 - (view) Author: Masaya Suzuki (draftcode) Date: 2013-01-02 13:50
Python 2.7.3 crushes when the following code is run without any library, which means run python with -S option:

    class Test:
        pass
    unicode(Test())

In the course of the interpreter tries to find the "__unicode__" attribute in a class, it uses a cached python string of "__unicode__". The reason of this crush is that the cached value is used before initialized. It is initialized only when trying to find the one of a new-style class, so the interpreter will crush if one uses only classic classes.

The attached patch will fix this issue by initializing a cached value before it is used.

Thanks.
msg178817 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-01-02 15:35
Thank you for the bug report.
msg178818 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-01-02 15:37
New changeset 0012d4f0ca59 by Benjamin Peterson in branch '2.7':
ensure the attribute name string is initalized before using it (closes #16839)
http://hg.python.org/cpython/rev/0012d4f0ca59
History
Date User Action Args
2013-02-21 02:33:36ned.deilylinkissue17260 superseder
2013-01-02 20:44:45jceasetnosy: + jcea
2013-01-02 15:37:52python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg178818

resolution: fixed
stage: patch review -> resolved
2013-01-02 15:35:16benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg178817
2013-01-02 14:32:32daniel.urbansetstage: patch review
2013-01-02 13:50:36draftcodecreate