summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_unicode.py6
-rw-r--r--Objects/unicodeobject.c4
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);