From: Marc-André Lemburg Date: Wed, 23 Oct 2002 09:02:46 +0000 (+0000) Subject: Fix for bug #626172: crash using unicode latin1 single char X-Git-Tag: v2.3c1~3694 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9cd87aaa54c2bfd3a2654cdd4e793f1e39389cac;p=thirdparty%2FPython%2Fcpython.git Fix for bug #626172: crash using unicode latin1 single char Python 2.2.3 candidate. --- diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 89e28b5b405f..cd40a4bbf1c9 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -434,6 +434,12 @@ vereq((u'ab' in 'abc'), True) vereq((u'ab' in (1,None,u'ab')), True) vereq((u'' in u'abc'), True) vereq(('' in u'abc'), True) +try: + u'\xe2' in 'g\xe2teau' +except UnicodeError: + pass +else: + print '*** contains operator does not propagate UnicodeErrors' print 'done.' # Formatting: diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5f9f4a70d144..c1cdebc0e8e9 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4485,10 +4485,8 @@ int PyUnicode_Contains(PyObject *container, goto onError; } u = (PyUnicodeObject *)PyUnicode_FromObject(container); - if (u == NULL) { - Py_DECREF(v); + if (u == NULL) goto onError; - } size = PyUnicode_GET_SIZE(v); rhs = PyUnicode_AS_UNICODE(v);