Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (revision 58704) +++ Objects/unicodeobject.c (working copy) @@ -2671,7 +2671,11 @@ startinpos = s-starts; /* \ - Escapes */ s++; - switch (*s++) { + if (s < end) + c = *s++; + else + c = 0; // Invalid for \ escape + switch (c) { /* \x escapes */ case '\n': break; @@ -2690,9 +2694,9 @@ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': x = s[-1] - '0'; - if ('0' <= *s && *s <= '7') { + if (s < end && '0' <= *s && *s <= '7') { x = (x<<3) + *s++ - '0'; - if ('0' <= *s && *s <= '7') + if (s < end && '0' <= *s && *s <= '7') x = (x<<3) + *s++ - '0'; } *p++ = x; @@ -2822,9 +2826,8 @@ break; default: - if (s > end) { + if (s >= end) { message = "\\ at end of string"; - s--; endinpos = s-starts; outpos = p-PyUnicode_AS_UNICODE(v); if (unicode_decode_call_errorhandler( Index: Include/stringobject.h =================================================================== --- Include/stringobject.h (revision 58704) +++ Include/stringobject.h (working copy) @@ -30,7 +30,6 @@ typedef struct { PyObject_VAR_HEAD long ob_shash; - int ob_placeholder; /* XXX If I remove this things break?!?! */ char ob_sval[1]; /* Invariants: