[issue8183] warn crashes if warning's __str__ returns Unicode

Ben Artin report at bugs.python.org
Sat Mar 20 18:07:03 CET 2010


New submission from Ben Artin <ba000484 at artins.org>:

Running the following script crashes my 2.6.1 interpreter on two different platforms:

from warnings import warn

class TestWarning(Warning):
	def __str__(self):
		return u'\u00ae'

warn(TestWarning())

Platforms I tried this on:

Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin

Python 2.6.1 (r261:67515, Dec 17 2008, 20:25:07) 
[GCC 3.4.6 [FreeBSD] 20060305] on freebsd6

Crash backtrace on Mac OS X:

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   org.python.python             	0x0000000100059e4c PyTuple_Pack + 154
1   org.python.python             	0x00000001000794c1 PyErr_Warn + 468
2   org.python.python             	0x000000010007922b _PyUnicodeUCS2_IsNumeric + 5504
3   org.python.python             	0x0000000100079fc8 PyErr_WarnExplicit + 1113
4   org.python.python             	0x00000001000951df PyEval_EvalFrameEx + 15001
5   org.python.python             	0x0000000100096ccf PyEval_EvalCodeEx + 1803
6   org.python.python             	0x0000000100096d62 PyEval_EvalCode + 54
7   org.python.python             	0x00000001000ae65a Py_CompileString + 78
8   org.python.python             	0x00000001000b04dd PyRun_InteractiveOneFlags + 503
9   org.python.python             	0x00000001000b0615 PyRun_InteractiveLoopFlags + 206
10  org.python.python             	0x00000001000b0685 PyRun_AnyFileExFlags + 76
11  org.python.python             	0x00000001000bc286 Py_Main + 2718
12  python                        	0x0000000100000e6c start + 52

----------
components: Library (Lib)
messages: 101379
nosy: bromine
severity: normal
status: open
title: warn crashes if warning's __str__ returns Unicode
type: crash
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8183>
_______________________________________


More information about the Python-bugs-list mailing list