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.

classification
Title: Segfault when stringifying UnicodeEncodeError (or UnicodeDecodeError) created with __new__()
Type: crash Stage: resolved
Components: Unicode Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Marek.Kowalski, benjamin.peterson, ezio.melotti, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2014-04-02 14:10 by Marek.Kowalski, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
segv.py Marek.Kowalski, 2014-04-02 14:10 Minial script causing segfault
Messages (10)
msg215384 - (view) Author: Marek Kowalski (Marek.Kowalski) Date: 2014-04-02 14:10
I'm attaching a minimal script to reproduce. I tested only with 3.2 and 2.7 versions. Its possible that it has been fixed since 3.2.
msg215386 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-04-02 14:44
Python 3.2 is not getting bugfixes anymore, only 3.4 and 3.5 (and 2.7).
msg215389 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-04-02 16:17
New changeset 140c5da3dc82 by Benjamin Peterson in branch '3.4':
bail in unicode error's __str__ methods if the objects are not properly initialized (closes #21134)
http://hg.python.org/cpython/rev/140c5da3dc82

New changeset afa7fb2cbe3b by Benjamin Peterson in branch '2.7':
bail in unicode error's __str__ methods if the objects are not properly initialized (closes #21134)
http://hg.python.org/cpython/rev/afa7fb2cbe3b

New changeset 0aeaea247d7d by Benjamin Peterson in branch 'default':
merge 3.4 (#21134)
http://hg.python.org/cpython/rev/0aeaea247d7d
msg215390 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-04-02 17:11
Benjamin: I don't like your change. You silently ignore the error. I would prefer to raise an exception on str(exc) if the Unicode exception object was not properly initialized.
msg215391 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-04-02 17:39
I don't care as long as it doesn't segfault.
msg254675 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-11-14 23:59
Do you have a patch Victor?
msg254695 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-11-15 20:56
> Do you have a patch Victor?

Nope.
msg269421 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-28 07:29
An empty string is the result of str() on an instance created with __new__ for all standard exceptions except SyntaxError (str() returnns 'None' for the latter, and this looks as a bug). Since there was no complains on this issue, I think it can be closed.
msg269424 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-06-28 07:59
> Since there was no complains on this issue, I think it can be closed.

I have a complain: we should not ignore bugs. IMO an exception must be raised.
msg269426 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-28 08:32
What is the bug here (except fixed segfault)?
History
Date User Action Args
2022-04-11 14:58:01adminsetgithub: 65333
2016-12-11 07:50:44serhiy.storchakasetstatus: pending -> closed
resolution: fixed
2016-11-28 23:31:48serhiy.storchakasetstatus: open -> pending
2016-06-28 08:32:30serhiy.storchakasetmessages: + msg269426
2016-06-28 07:59:24vstinnersetstatus: pending -> open

messages: + msg269424
2016-06-28 07:29:54serhiy.storchakasetstatus: open -> pending

messages: + msg269421
2015-11-15 20:56:10vstinnersetmessages: + msg254695
2015-11-14 23:59:35serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg254675
2014-04-02 17:39:26benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg215391
2014-04-02 17:11:36vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg215390
2014-04-02 16:17:07python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg215389

resolution: fixed
stage: resolved
2014-04-02 14:44:38vstinnersetmessages: + msg215386
versions: + Python 3.4, Python 3.5, - Python 3.2
2014-04-02 14:10:37Marek.Kowalskicreate