From 9cd87aaa54c2bfd3a2654cdd4e793f1e39389cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lemburg?= Date: Wed, 23 Oct 2002 09:02:46 +0000 Subject: Fix for bug #626172: crash using unicode latin1 single char Python 2.2.3 candidate. --- Lib/test/test_unicode.py | 6 ++++++ Objects/unicodeobject.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 89e28b5..cd40a4b 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 5f9f4a7..c1cdebc 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); -- cgit v0.12