classification
Title: Segfault from calling repr() on a dict with a key whose repr raise an exception
Type: crash Stage: resolved
Components: Interpreter Core, Unicode Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: christian.heimes, david.m.cooke, ezio.melotti, python-dev, r.david.murray, serhiy.storchaka
Priority: normal Keywords: 3.3regression, patch

Created on 2013-01-03 23:30 by david.m.cooke, last changed 2013-01-04 10:48 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
unicode_append.patch serhiy.storchaka, 2013-01-04 09:41 review
Messages (6)
msg178997 - (view) Author: David M. Cooke (david.m.cooke) Date: 2013-01-03 23:30
The following segfaults:

class A(int):
    def __repr__(self):
        raise Exception()
a = A()
d = {a : 1}
repr(d)

This is with Python 3.3.0, running on Mac OS 10.7.5, from MacPorts:
Python 3.3.0 (default, Sep 29 2012, 08:16:08) 
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin
msg178998 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-01-03 23:40
Confirmed on Gentoo linux.  On default, too.  This is a regression from 3.2.
msg179008 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-04 09:41
Here is a patch.
msg179009 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-01-04 09:45
IMO the check is better performed a couple of lines later:

if (right == NULL || left == NULL || !PyUnicode_Check(left)) {
msg179015 - (view) Author: Roundup Robot (python-dev) Date: 2013-01-04 10:42
New changeset 3cee61137598 by Serhiy Storchaka in branch '3.3':
Issue #16856: Fix a segmentation fault from calling repr() on a dict with
http://hg.python.org/cpython/rev/3cee61137598

New changeset fee4bc043d73 by Serhiy Storchaka in branch 'default':
Issue #16856: Fix a segmentation fault from calling repr() on a dict with
http://hg.python.org/cpython/rev/fee4bc043d73
msg179016 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-04 10:48
> IMO the check is better performed a couple of lines later:

Done.

Thank you for report, David.
History
Date User Action Args
2013-01-04 10:48:32serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg179016

stage: patch review -> resolved
2013-01-04 10:42:04python-devsetnosy: + python-dev
messages: + msg179015
2013-01-04 09:45:37christian.heimessetnosy: + christian.heimes
messages: + msg179009
2013-01-04 09:41:31serhiy.storchakasetfiles: + unicode_append.patch

assignee: serhiy.storchaka
components: + Unicode

keywords: + 3.3regression, patch
nosy: + serhiy.storchaka, ezio.melotti
messages: + msg179008
stage: patch review
2013-01-03 23:40:26r.david.murraysetnosy: + r.david.murray

messages: + msg178998
versions: + Python 3.4
2013-01-03 23:30:51david.m.cookecreate